Absolute URLs with Grunt Usemin / CSSmin while still finding the CSS

217 views Asked by At

Because my site is based on folder structure, I have to add as many ../ as their are levels in the hierarchy or on deeper 'pages' the CSS doesn't load.

Is there a way to get Grunt Usemin / CSSmin to let me use an absolute url?

<!-- build:css(.tmp) ../../assets/styles/main.css -->
<link rel='stylesheet' href='../.tmp/styles/main.css'/>
<!-- endbuild -->

When I use /assets/styles/main.css, usemin doesn't find the CSS to minify (but the URL in the HTML is rewritten to the correct absolute url).

Is there a solution in the config of usemin or cssmin?

Below are the relevant parts from my Gruntfile. The full file is on PasteBin

useminPrepare: {
  options: {
    dest: '<%= config.dist.assets %>'
  },
  html: ['.tmp/templates/{,*/}*.html', '.tmp/snippets/{,*/}*.html']
},

usemin: {
  options: {
    assetDirs: '<%= config.dist.assets %>',
    basedir: '',
    dirs: '<%= config.app.root %>'
  },
  html: ['.tmp/templates/{,*/}*.html', '.tmp/snippets/{,*/}*.html'],
  css: '.tmp/styles/{,*/}*.css'
},
0

There are 0 answers