找不到名为“ sourcemap”的选项-Grunt watch

问题描述 投票:0回答:1

[This is the error Grunt正在运行并且正在检测更改,但是由于错误“找不到名为” sourcemap“的选项”而未进行编译

未安装Ruby,因为之前已安装它,所以我安装了它。更新了package.json文件中的所有节点包。据我所知,SCSS / CSS文件位于正确的路径中,不确定是什么问题。

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']);
};
gruntjs grunt-contrib-watch
1个回答
0
投票
我遇到了同样的问题。我最近切换了机器,并升级到OS Catalina(不确定这是否与错误有关)。

对我有用的(临时)解决方案是编辑Gruntfile.js并删除'sourcemap'选项:

之前:

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

之后:

options: { style: 'compressed' },
© www.soinside.com 2019 - 2024. All rights reserved.