gpt4 book ai didi

javascript - 无法运行 Grunt `watch` 任务?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:19:05 24 4
gpt4 key购买 nike

下面是我的 Grunt 文件。我的 watch:news 命令似乎不起作用,我不确定原因。

当我在详细模式下运行时,我可以看到所有 NPM 模块都已加载,没有问题,并且它验证了 watch:news 任务正在按应有的方式运行,但它只是没有'发现发生了任何变化?

我确定这可能是一个拼写错误或一些小的/容易解决的问题,我就是无法发现它?

非常感谢任何帮助!

module.exports = function (grunt) {

/*
Grunt installation:
-------------------
npm install -g grunt-cli
npm install -g grunt-init
npm init (creates a `package.json` file)

Project Dependencies:
---------------------
npm install grunt --save-dev
npm install grunt-contrib-watch --save-dev
npm install grunt-contrib-jshint --save-dev
npm install grunt-contrib-uglify --save-dev
npm install grunt-contrib-requirejs --save-dev
npm install grunt-contrib-sass --save-dev
npm install grunt-contrib-imagemin --save-dev

Example Usage:
--------------
grunt -v
grunt release -v
*/

// Project configuration.
grunt.initConfig({

// Store your Package file so you can reference its specific data whenever necessary
pkg: grunt.file.readJSON('package.json'),

dir: {
static: './tabloid/webapp/static/',
static_js: '<%= dir.static %>' + 'js/',
static_sass: '<%= dir.static %>' + 'sass/',
static_css: '<%= dir.static %>' + 'stylesheets/',
static_img: '<%= dir.static %>' + 'img/'
},

jshint: {
files: ['<%= dir.static %>**/*.js',
'!<%= dir.static_js %>jasmine/lib/**/*.js',
'!<%= dir.static_js %>build.js',
'!<%= dir.static_js %>compiled/**/*.js',
'!<%= dir.static_js %>locator/**/*.js',
'!<%= dir.static_js %>msie/**/*.js',
'!<%= dir.static_js %>vendor/**/*.js'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
multistr: true,
newcap: false,

globals: {
// AMD
module: true,
require: true,
requirejs: true,
define: true,

// Environments
console: true,

// General Purpose Libraries
$: true,
jQuery: true,
EventEmitter: true,

// Testing
sinon: true,
describe: true,
it: true,
expect: true,
beforeEach: true,
afterEach: true
}
}
},

requirejs: {
compile: {
options: {
baseUrl: '<%= dir.static_js %>',
paths: {
'jquery-1': 'vendor/jquery-1/jquery.min',
'jquery': 'vendor/jquery-2/jquery.min',
'domReady': 'vendor/require/domReady',
'translation': 'module/translations/news'
},
exclude: ['config', 'jquery' ],
name: 'define',
out: '<%= dir.static_js %>compiled/all.js',
fileExclusionRegExp: /^\.|node_modules|Gruntfile|\.md|package.json/
}
}
},

sass: {
dist: {
options: {
style: 'compressed',
require: ['<%= dir.static_sass %>helpers/url64.rb']
},
expand: true,
cwd: '<%= dir.static_sass %>',
src: ['*.scss', '!_*.scss'],
dest: '<%= dir.static_css %>',
ext: '.css'
},
dev: {
options: {
style: 'expanded',
debugInfo: true,
lineNumbers: true,
require: ['<%= dir.static_sass %>helpers/url64.rb']
},
expand: true,
cwd: '<%= dir.static_sass %>',
src: ['*.scss', '!_*.scss'],
dest: '<%= dir.static_css %>',
ext: '.css'
},
news: {
options: {
style: 'expanded',
debugInfo: true,
lineNumbers: true,
require: ['<%= dir.static_sass %>helpers/url64.rb']
},
expand: true,
cwd: '<%= dir.static_sass %>/services/news/',
src: ['*.scss'],
dest: '<%= dir.static_css %>/services/news/',
ext: '.css'
}
},

// `optimizationLevel` is only applied to PNG files (not JPG)
imagemin: {
png: {
options: {
optimizationLevel: 7
},
files: [
{
expand: true,
cwd: '<%= dir.static %>img/',
src: ['**/*.png'],
dest: '<%= dir.static %>img/',
ext: '.png'
}
]
},
jpg: {
options: {
progressive: true
},
files: [
{
expand: true,
cwd: '<%= dir.static %>img/',
src: ['**/*.jpg'],
dest: '<%= dir.static %>img/',
ext: '.jpg'
}
]
}
},

// Run: `grunt watch -v` from command line for this section to take effect
// The -v flag is for 'verbose' mode, this means you can see the Sass files being compiled along with other important information
watch: {
all: {
files: ['<%= jshint.files %>', '<%= sass.dev.src %>'],
tasks: ['default']
},
news: {
files: ['<%= sass.news.src %>'],
tasks: ['news']
}
}

});

// Load NPM Tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-imagemin');

// Default Task
grunt.registerTask('default', ['jshint', 'sass:dev']);

// News Task
grunt.registerTask('news', ['sass:news']);

// Release Task
grunt.registerTask('release', ['jshint', 'requirejs', 'sass:dist', 'imagemin']);

};

最佳答案

发现问题与观看 <%= sass.news.src %> 有关这不起作用,因为我们正在使用 Grunt 的扩展目录 globbing。

解决方案是直接引用我想看的文件夹:<%= dir.static_sass %>**/*.scss'

关于javascript - 无法运行 Grunt `watch` 任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16831705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com