1

I am trying to configure my Gruntfile to auto-generate sourcemaps for my CSS files. I have several unminified CSS files which I combine into one minified file, but I would like to reference the unminified files for debugging in dist/src/_assets/css/ via the sourcemap. I am using grunt-contrib-cssmin version 0.14.0 and grunt 0.4.5.

My goal project structure is roughly:

  • dist
    • _assets
      • css
    • src
      • _assets
        • css
  • src
    • _assets
      • css

My grunt-contrib-cssmin config is:

        cssmin: {
            options: {
                keepSpecialComments: false,
                sourceMap: true
            },
            build: {
                files: {
                    'dist/_assets/css/portfolio.css': [
                        'src/_assets/css/bootstrap.css',
                        'src/_assets/css/font-awesome.css',
                        'src/_assets/css/portfolio.css'
                    ]
                }
            }
        },

I have a separate copy task that copies bootstrap.css, font-awesome.css, and portfolio.css to dist/src/_assets/css, but for some reason, the sourcemap is trying to reference dist/_assets/css/src/_assets/css/ instead of dist/src/_assets/css. Is there any way I can modify the directory the sourcemap is looking at without having to modify the sourcemap manually? This is pretty confusing to me because essentially the same settings in grunt-contrib-uglify do exactly what I want regarding sourcemaps (i.e. they reference dist/src/_assets/js).

2 Answers 2

2

Well, I gave up on trying to configure the sourcemap paths directly in grunt-contrib-cssmin and just used grunt-text-replace to get my paths squared away:

replace: {
    build: {
        src: 'dist/_assets/css/portfolio.css.map',
        dest: 'dist/_assets/css/',
        replacements: [
            {
                from: 'src/_assets/css/',
                to: '../../../src/_assets/css/'
            }
        ]
    }
},
Sign up to request clarification or add additional context in comments.

Comments

0

grunt-contrib-cssmin do not provide any sourcemap path option like feature til now. I recommend to use the cssmin only for production not for development.

"csswring" by the Kyo Nagashima might be the solution for your problem...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.