Grunt cssmin rebasing a relative URI?

后端 未结 2 2010
忘掉有多难
忘掉有多难 2021-01-05 09:49

I\'m currently setting up grunt-usemin for our project but I\'m running in a small issue with the cssmin task.

Our project depends on a few external lib

相关标签:
2条回答
  • 2021-01-05 10:44

    I have a grunt file in C:\web\project and CSS files in C:\web\project\www\css. The following snippet is from my grunt file and it rebases URLs correctly for me.

    var cssFiles = [
          'www/css/layout/Header.css',
          'www/css/layout/Footer.css',
          'www/css/vendor/chosen/chosen.css'
          // ...
    ];
    
    cssmin: {
            concat: {
                    options: {
                            keepBreaks: true, //  whether to keep line breaks (default is false)
                            debug: true, // set to true to get minification statistics under 'stats' property (see test/custom-test.js for examples)
                            noAdvanced: true, // set to true to disable advanced optimizations - selector & property merging, reduction, etc.
                            //relativeTo: 'http://online-domain-tools.com/'
                            noRebase: false, // whether to skip URLs rebasing
                            root: 'www'
                    },
                    nonull: true,
                    src: cssFiles,
                    dest: 'www/temp/application.css'
            },
            minify: {
                    options: {},
                    nonull: true,
                    src: ['www/temp/application.css'],
                    dest: 'www/temp/application.min.css'
            }
    },
    
    // ...
    
    grunt.registerTask('default', ['cssmin:concat', 'cssmin:minify']);
    

    Can you post your gruntfile to compare it?

    Related reading: https://stackoverflow.com/a/21415649/99256

    0 讨论(0)
  • 2021-01-05 10:44

    look in the cssmin documentation/options:

    • rebase: set to false to skip URL rebasing

    That solves the issue.

    0 讨论(0)
提交回复
热议问题