grunt-contrib-less: compilation on watch task removes sourcemap link

醉酒当歌 提交于 2019-12-12 01:39:53

问题


Here's my less task config:

less: {
    development: {
        options: {
            compress: false,
            sourceMap: true,
            yuicompress: true,
            sourceMapFilename: 'export/style/app.css.map',
            sourceMapURL: '/style/app.css.map'
        },

        files: {
            "export/style/app.css": "less/app.less"
        }
    }
},

If I just type grunt less, in my compiled file i get the /*# sourceMappingURL=/style/app.css.map */ comment correctly.

Instead, when i run grunt and my watch task kicks in, the /*# sourceMappingURL=/style/app.css.map */ comment is removed on compilation.

Here's my watch task for less:

watch: {
    less: {
        files: ['less/*.less'],
        tasks: ['less', 'postcss'],
        options: {
            livereload: true,
            nospaces: true
        }
    }
},

What am I doing wrong?


回答1:


it was actually the postcss task preventing the comment to appear. fixed with

postcss: {
    options: {
      map: true,


来源:https://stackoverflow.com/questions/34616876/grunt-contrib-less-compilation-on-watch-task-removes-sourcemap-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!