gruntfile.js
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
//Read the package.json (optional)
pkg: grunt.file.readJSON('package.json'),
// Metadata.
meta: {
srcJsPath: './static/js/',
srcSassPath: './static/css/',
srcImgPath: './static/images/',
distPath: './static/dist/'
},
//babel
babel: {
options: {
sourceMap: true,
presets: ['env']
},
dist: {
files: [{
expand:true,
cwd:'static/js/', //js目录下
src: '*.js', //所有js文件
dest:'static/dist/' //输出到此目录下
}]
}
},
// sass
sass: {
dist: {
options: {
style: 'compressed',
sourcemap: 'none'
},
files: [
{'<%= meta.distPath %>nav_list.css': '<%= meta.srcSassPath %>nav_list.scss'},
]
}
},
watch: {
build: {
files: [
'<%= meta.srcJsPath %>*.js', '<%= meta.srcSassPath %>*.scss',
],
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
// 默认被执行的任务列表。
grunt.registerTask('default', ['sass', 'babel', 'watch']);
};
项目目录是这样的
运行grunt 总报错
scss可以转换成功,es6转es5不能成功
慕神8447489