我已经按如下方式配置了gruntfile。当我执行" grunt"命令提示符下的命令,jshint,clean和concat任务工作正常,但是当执行cssmin任务时,它会发出以下错误。
还有一点要提到的是,当我重新启动系统时,没有收到任何错误,并且工作流程顺畅,并产生所需的结果。 可能有任何一点原因造成这个问题。
这是我的gruntfile.js
'use strict';
module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {useminPrepare: 'grunt-usemin'});
// Define the configuration for all the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
//The JSHint task is set to examine all the JavaScript files in the app/scripts folder, and the Gruntfile.js and generate any reports of JS errors or warnings.
'Gruntfile.js',
'app/scripts/{,*/}*.js'
]
}
},
copy: {
dist: {
cwd: 'app',
src: [ '**','!styles/**/*.css','!scripts/**/*.js' ],
dest: 'dist',
expand: true
},
fonts: {
files: [
{
//for bootstrap fonts
expand: true,
dot: true,
cwd: 'bower_components/bootstrap/dist',
src: ['fonts/*.*'],
dest: 'dist'
},
{
//for font-awesome
expand: true,
dot: true,
cwd: 'bower_components/font-awesome',
src: ['fonts/*.*'],
dest: 'dist'
}
]
}
},
clean: {
build: {
src: [ 'dist/']
}
},
useminPrepare: {
html: 'app/menu.html',
options: {
dest: 'dist'
}
},
// Concat
concat: {
options: {
separator: ';'
},
// dist configuration is provided by useminPrepare
dist: {}
},
// Uglify
uglify: {
// dist configuration is provided by useminPrepare
dist: {}
},
cssmin: {
dist: {}
},
// Filerev
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
release: {
// filerev:release hashes(md5) all assets (images, js and css in dist directory
files: [{
src: [
'dist/scripts/*.js',
'dist/styles/*.css',
]
}]
}
},
// Usemin
// Replaces all assets with their revved version in html and css files.
// options.assetDirs contains the directories for finding the assets
// according to their relative paths
usemin: {
html: ['dist/*.html'],
css: ['dist/styles/*.css'],
options: {
assetsDirs: ['dist', 'dist/styles']
}
},
watch: {
copy: {
files: [ 'app/**', '!app/**/*.css', '!app/**/*.js'],
tasks: [ 'build' ]
},
scripts: {
files: ['app/scripts/app.js'],
tasks:[ 'build']
},
styles: {
files: ['app/styles/mystyles.css'],
tasks:['build']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'app/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'app/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
dist: {
options: {
open: true,
base:{
path: 'dist',
options: {
index: 'menu.html',
maxAge: 300000
}
}
}
}
}
});
grunt.registerTask('build', ['clean', 'jshint', 'useminPrepare',
'concat', 'cssmin', 'uglify', 'copy', 'filerev', 'usemin']);
grunt.registerTask('default', ['build']);
grunt.registerTask('serve',['build','connect:dist','watch']);
};
答案 0 :(得分:0)
以下代码可能对您有所帮助:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': '100.10.10.5',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'password',
},
}
没有//grunt.registerTask('build', ['styles', 'static']);
grunt.registerTask('build', function() {
grunt.file.mkdir('build/js');
grunt.file.mkdir('build/fonts');
grunt.file.mkdir('build/css');
grunt.task.run(['stylus', 'copy', 'browserify']);
});
grunt.registerTask('default', ['build', 'watch']);
文件夹,在运行构建任务之前创建一个文件夹。
答案 1 :(得分:0)
在我的情况下,问题是我需要在复制任务的目标路径中添加尾部斜杠,即从dist
到dist/
;它正在输出到文件dist
而不是文件夹dist
。然后,当cssmin尝试创建dist/css
时,由于dist不是文件夹而无法创建。
坏:
copy: {
html: {
files: [{
expand: true,
dot: true,
cwd: './',
src: ['*.html'],
dest: 'dist'
}],
已更正:
copy: {
html: {
files: [{
exxpand: true,
dot: true,
cwd: './',
src: ['*.html'],
dest: 'dist/'
}],