我对sails很新,并且不太了解使用gruntjs文件.我有一个应用程序,加载了大量的js和css文件.我想将所有这些js文件缩小为1-2个缩小的js文件,并将所有css文件缩小为1个缩小的css文件…
截至目前,我不知道该怎么做,我试图在我的sailsjs应用程序中实现这个 – How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x)但在源代码中查看时没有打印缩小的css文件.
提前致谢.
这是sails v0.9.16的默认gruntfile
module.exports = function (grunt) {
var cssFilesToInject = [ 'linker/**/*.css' ];
var jsFilesToInject = [ 'linker/**/*.js' ];
var templateFilesToInject = [ 'linker/**/*.html' ];
cssFilesToInject = cssFilesToInject.map(function (path) {
return '.tmp/public/' + path;
});
jsFilesToInject = jsFilesToInject.map(function (path) {
return '.tmp/public/' + path;
});
templateFilesToInject = templateFilesToInject.map(function (path) {
return 'assets/' + path;
});
var depsPath = grunt.option('gdsrc') || 'node_modules/sails/node_modules';
grunt.loadTasks(depsPath + '/grunt-contrib-clean/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-copy/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-concat/tasks');
grunt.loadTasks(depsPath + '/grunt-sails-linker/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-jst/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-watch/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-uglify/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-cssmin/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-less/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-coffee/tasks');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),copy: {
dev: {
files: [
{
expand: true,cwd: './assets',src: ['**/*.!(coffee)'],dest: '.tmp/public'
}
]
},build: {
files: [
{
expand: true,cwd: '.tmp/public',src: ['**/*'],dest: 'www'
}
]
}
},clean: {
dev: ['.tmp/public/**'],build: ['www']
},jst: {
dev: {
files: {
'.tmp/public/jst.js': templateFilesToInject
}
}
},less: {
dev: {
files: [
{
expand: true,cwd: 'assets/styles/',src: ['*.less'],dest: '.tmp/public/styles/',ext: '.css'
},{
expand: true,cwd: 'assets/linker/styles/',dest: '.tmp/public/linker/styles/',ext: '.css'
}
]
}
},coffee: {
dev: {
options:{
bare:true
},files: [
{
expand: true,cwd: 'assets/js/',src: ['**/*.coffee'],dest: '.tmp/public/js/',ext: '.js'
},{
expand: true,cwd: 'assets/linker/js/',dest: '.tmp/public/linker/js/',ext: '.js'
}
]
}
},concat: {
js: {
src: jsFilesToInject,dest: '.tmp/public/concat/production.js'
},css: {
src: cssFilesToInject,dest: '.tmp/public/concat/production.css'
}
},uglify: {
dist: {
src: ['.tmp/public/concat/production.js'],dest: '.tmp/public/min/production.js'
}
},cssmin: {
dist: {
src: ['.tmp/public/concat/production.css'],dest: '.tmp/public/min/production.css'
}
},'sails-linker': {
devJs: {
options: {
startTag: ' 原文链接:https://www.f2er.com/css/427192.html