gruntjsgrunt-contrib-watch

Could not find an option named "sourcemap" - Grunt watch


This is the errorGrunt is running and detecting the change but the compilation is not happening due to the error "Could not find an option named "sourcemap"

Ruby was not installed since it was required before, I installed it. Updated all the node packages inside the package.json file. SCSS/CSS files are in the correct path as fas as I know, not sure what could be the issue.

ui = {
	'grunt' : 
	{
		'js_files' :
		[
			'web/webroot/_ui/responsive/theme-blue/razer/js/jquery-ui-1.11.2.custom.min.js'
		]
	}
}

//'use strict';
module.exports = function (grunt) {
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        //Compile Sass
        sass: {
            options: {
                sourcemap: 'none'
            },
            compile: {
                files: {
                    'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.scss',
                    'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.home.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.home.scss',
                    'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.branding.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.branding.scss',
                    'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.whitepdp.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.whitepdp.scss'
                }
            }
        },
        //Minify css
        cssmin: {
            target: {
                files: [
                    {
                        src: [
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
                        ],
                        dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.css'
                    },
                    {
                        src: [
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.home.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
                        ],
                        dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.home.css'
                    },
                    {
                        src: [
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.branding.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
                        ],
                        dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.branding.css'
                    },
                    {
                        src: [
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.whitepdp.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
                            'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
                        ],
                        dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.whitepdp.css'
                    }
                ]
            }
        },
        imagemin: { // Task
            dynamic: { // Another target
                files: [{
                    expand: true, // Enable dynamic expansion
                    cwd: 'web/webroot/_ui/responsive/theme-blue/razer/images/', // Src matches are relative to this path
                    src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
                    dest: 'web/webroot/_ui/responsive/theme-blue/razer/images/' // Destination path prefix
                }]
            }
        },
        //Uglify js
        uglify: {
            build: {
                files: [{
                    src: ui.grunt.js_files,
                    dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined.js'
                }],
                files: [{
                    src: [
                        'web/webroot/_ui/responsive/common/js/jquery-2.1.1.min.js'


                    ],
                    dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined_lib.js'
                }],
                files: [{
                    src: [
                        'web/webroot/_ui/responsive/common/js/jquery-2.1.1.min.js'


                    ],
                    dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined_lib.js'
                }]
            },


            debug: {
                options: {
                    beautify: false,
                    mangle: false,
                    compress: true
                },
                files: [{
                    src: ui.grunt.js_files,
                    dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined.js'
                }]
            }
        },
        watch: {
            css: {
                files: ['**/*.scss', '**/*.css'],
                tasks: ['sass', 'cssmin']
            },

            build: {
                files: ['web/webroot/_ui/responsive/theme-blue/razer/js/*.js', 'web/webroot/_ui/responsive/common/js/*.js', 'web/webroot/_ui/responsive/theme-blue/razer/js/plugin/*.js'], // which files to watch
                tasks: ['uglify:build'],
                options: {
                    nospawn: true
                }
            },
            debug: {
                files: ['web/webroot/_ui/responsive/theme-blue/razer/js/*.js', 'web/webroot/_ui/responsive/common/js/*.js'], // which files to watch
                tasks: ['uglify:debug'],
                options: {
                    nospawn: true
                }
            }
        }
    });

    // Plugins
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    //grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.registerTask('build', ['watch']);

    grunt.registerTask('default', ['sass', 'cssmin', 'uglify']);
    grunt.registerTask('debug', ['uglify:debug', 'watch:debug']);
    grunt.registerTask('lib', ['uglify:lib']);
};


Solution

  • I am experiencing the same issue. I recently switched machines and upgraded to OS Catalina (not sure if this is related to the error).

    A (temporary) solution that worked for me is to edit Gruntfile.js and remove the 'sourcemap' option:

    before:

    options: {
          style: 'compressed',
          sourcemap: true
        },
    

    after:

    options: {
          style: 'compressed'
        },