Initial project structure with sails.js
This commit is contained in:
54
tasks/config/babel.js
Normal file
54
tasks/config/babel.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* `tasks/config/babel`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Transpile >=ES6 code for broader browser compatibility.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/babel.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('babel', {
|
||||
dist: {
|
||||
options: {
|
||||
presets: [require('sails-hook-grunt/accessible/babel-preset-env')]
|
||||
},
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: '.tmp/public',
|
||||
src: ['js/**/*.js'],
|
||||
dest: '.tmp/public'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-babel --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-babel');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
52
tasks/config/clean.js
Normal file
52
tasks/config/clean.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* `tasks/config/clean`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Remove generated files and folders.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/clean.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('clean', {
|
||||
dev: ['.tmp/public/**'],
|
||||
build: ['www'],
|
||||
afterBuildProd: [
|
||||
'www/concat',
|
||||
'www/min',
|
||||
'www/hash',
|
||||
'www/js',
|
||||
'www/styles',
|
||||
'www/templates',
|
||||
'www/dependencies'
|
||||
]
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-clean --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
50
tasks/config/concat.js
Normal file
50
tasks/config/concat.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* `tasks/config/concat`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* An intermediate step to generate monolithic files that can
|
||||
* then be passed in to `uglify` and/or `cssmin` for minification.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/concat.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('concat', {
|
||||
js: {
|
||||
src: require('../pipeline').jsFilesToInject,
|
||||
dest: '.tmp/public/concat/production.js'
|
||||
},
|
||||
css: {
|
||||
src: require('../pipeline').cssFilesToInject,
|
||||
dest: '.tmp/public/concat/production.css'
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-concat --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
65
tasks/config/copy.js
Normal file
65
tasks/config/copy.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* `tasks/config/copy`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Copy files and/or folders.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/copy.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('copy', {
|
||||
dev: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: './assets',
|
||||
src: ['**/*.!(coffee|less)'],
|
||||
dest: '.tmp/public'
|
||||
}]
|
||||
},
|
||||
build: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: '.tmp/public',
|
||||
src: ['**/*'],
|
||||
dest: 'www'
|
||||
}]
|
||||
},
|
||||
beforeLinkBuildProd: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: '.tmp/public/hash',
|
||||
src: ['**/*'],
|
||||
dest: '.tmp/public/dist'
|
||||
}]
|
||||
},
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-copy --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
47
tasks/config/cssmin.js
Normal file
47
tasks/config/cssmin.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* `tasks/config/cssmin`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Together with the `concat` task, this is the final step that minifies
|
||||
* all CSS files from `assets/styles/` (and potentially your LESS importer
|
||||
* file from `assets/styles/importer.less`)
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/cssmin.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('cssmin', {
|
||||
dist: {
|
||||
src: ['.tmp/public/concat/production.css'],
|
||||
dest: '.tmp/public/min/production.min.css'
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-cssmin --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-cssmin');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
62
tasks/config/hash.js
Normal file
62
tasks/config/hash.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* `tasks/config/hash`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Implement cache-busting for minified CSS and JavaScript files.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/hash.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('hash', {
|
||||
options: {
|
||||
mapping: '',
|
||||
srcBasePath: '',
|
||||
destBasePath: '',
|
||||
flatten: false,
|
||||
hashLength: 8,
|
||||
hashFunction: function(source, encoding){
|
||||
if (!source || !encoding) {
|
||||
throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: '+require('util').inspect(source, {depth:null})+'\nencoding: '+require('util').inspect(encoding, {depth:null}));
|
||||
}
|
||||
return require('crypto').createHash('sha1').update(source, encoding).digest('hex');
|
||||
}
|
||||
},
|
||||
js: {
|
||||
src: '.tmp/public/min/*.js',
|
||||
dest: '.tmp/public/hash/'
|
||||
},
|
||||
css: {
|
||||
src: '.tmp/public/min/*.css',
|
||||
dest: '.tmp/public/hash/'
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-hash --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-hash');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
50
tasks/config/less.js
Normal file
50
tasks/config/less.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* `tasks/config/less`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Compile your LESS files into a CSS stylesheet.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/less.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('less', {
|
||||
dev: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'assets/styles/',
|
||||
src: ['importer.less'],
|
||||
dest: '.tmp/public/styles/',
|
||||
ext: '.css'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-less --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-less');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
184
tasks/config/sails-linker.js
Normal file
184
tasks/config/sails-linker.js
Normal file
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* `tasks/config/sails-linker`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Automatically inject <script> tags and <link> tags into the specified
|
||||
* specified HTML and/or EJS files. The specified delimiters (`startTag`
|
||||
* and `endTag`) determine the insertion points.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/sails-linker.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('sails-linker', {
|
||||
|
||||
|
||||
// ╦╔═╗╦ ╦╔═╗╔═╗╔═╗╦═╗╦╔═╗╔╦╗
|
||||
// ║╠═╣╚╗╔╝╠═╣╚═╗║ ╠╦╝║╠═╝ ║
|
||||
// ╚╝╩ ╩ ╚╝ ╩ ╩╚═╝╚═╝╩╚═╩╩ ╩
|
||||
// ┌─ ┌─┐┬ ┬┌─┐┌┐┌┌┬┐ ┌─┐┬┌┬┐┌─┐ ┬┌─┐┬ ┬┌─┐┌─┐┌─┐┬─┐┬┌─┐┌┬┐ ─┐
|
||||
// │─── │ │ │├┤ │││ │───└─┐│ ││├┤ │├─┤└┐┌┘├─┤└─┐│ ├┬┘│├─┘ │ ───│
|
||||
// └─ └─┘┴─┘┴└─┘┘└┘ ┴ └─┘┴─┴┘└─┘ └┘┴ ┴ └┘ ┴ ┴└─┘└─┘┴└─┴┴ ┴ ─┘
|
||||
devJs: {
|
||||
options: {
|
||||
startTag: '<!--SCRIPTS-->',
|
||||
endTag: '<!--SCRIPTS END-->',
|
||||
fileTmpl: '<script src="%s"></script>',
|
||||
appRoot: '.tmp/public'
|
||||
},
|
||||
files: {
|
||||
'.tmp/public/**/*.html': require('../pipeline').jsFilesToInject,
|
||||
'views/**/*.html': require('../pipeline').jsFilesToInject,
|
||||
'views/**/*.ejs': require('../pipeline').jsFilesToInject
|
||||
}
|
||||
},
|
||||
|
||||
devJsBuild: {
|
||||
options: {
|
||||
startTag: '<!--SCRIPTS-->',
|
||||
endTag: '<!--SCRIPTS END-->',
|
||||
fileTmpl: '<script src="%s"></script>',
|
||||
appRoot: '.tmp/public',
|
||||
// relative: true
|
||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||
// (but be note that this can break custom font URLs)
|
||||
},
|
||||
files: {
|
||||
'.tmp/public/**/*.html': require('../pipeline').jsFilesToInject,
|
||||
'views/**/*.html': require('../pipeline').jsFilesToInject,
|
||||
'views/**/*.ejs': require('../pipeline').jsFilesToInject
|
||||
}
|
||||
},
|
||||
|
||||
prodJs: {
|
||||
options: {
|
||||
startTag: '<!--SCRIPTS-->',
|
||||
endTag: '<!--SCRIPTS END-->',
|
||||
fileTmpl: '<script src="%s"></script>',
|
||||
appRoot: '.tmp/public'
|
||||
},
|
||||
files: {
|
||||
'.tmp/public/**/*.html': ['.tmp/public/min/production.min.js'],
|
||||
'views/**/*.html': ['.tmp/public/min/production.min.js'],
|
||||
'views/**/*.ejs': ['.tmp/public/min/production.min.js']
|
||||
}
|
||||
},
|
||||
|
||||
prodJsBuild: {
|
||||
options: {
|
||||
startTag: '<!--SCRIPTS-->',
|
||||
endTag: '<!--SCRIPTS END-->',
|
||||
fileTmpl: '<script src="%s"></script>',
|
||||
appRoot: '.tmp/public',
|
||||
// relative: true
|
||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||
// (but be note that this can break custom font URLs)
|
||||
},
|
||||
files: {
|
||||
'.tmp/public/**/*.html': ['.tmp/public/dist/*.js'],
|
||||
'views/**/*.html': ['.tmp/public/dist/*.js'],
|
||||
'views/**/*.ejs': ['.tmp/public/dist/*.js']
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// ╔═╗╔╦╗╦ ╦╦ ╔═╗╔═╗╦ ╦╔═╗╔═╗╔╦╗╔═╗
|
||||
// ╚═╗ ║ ╚╦╝║ ║╣ ╚═╗╠═╣║╣ ║╣ ║ ╚═╗
|
||||
// ╚═╝ ╩ ╩ ╩═╝╚═╝╚═╝╩ ╩╚═╝╚═╝ ╩ ╚═╝
|
||||
// ┌─ ┬┌┐┌┌─┐┬ ┬ ┬┌┬┐┬┌┐┌┌─┐ ╔═╗╔═╗╔═╗ ┬ ┌─┐┌─┐┌┬┐┌─┐┬┬ ┌─┐┌┬┐ ╦ ╔═╗╔═╗╔═╗ ─┐
|
||||
// │─── │││││ │ │ │ │││││││ ┬ ║ ╚═╗╚═╗ ┌┼─ │ │ ││││├─┘││ ├┤ ││ ║ ║╣ ╚═╗╚═╗ ───│
|
||||
// └─ ┴┘└┘└─┘┴─┘└─┘─┴┘┴┘└┘└─┘ ╚═╝╚═╝╚═╝ └┘ └─┘└─┘┴ ┴┴ ┴┴─┘└─┘─┴┘ ╩═╝╚═╝╚═╝╚═╝ ─┘
|
||||
devStyles: {
|
||||
options: {
|
||||
startTag: '<!--STYLES-->',
|
||||
endTag: '<!--STYLES END-->',
|
||||
fileTmpl: '<link rel="stylesheet" href="%s">',
|
||||
appRoot: '.tmp/public'
|
||||
},
|
||||
|
||||
files: {
|
||||
'.tmp/public/**/*.html': require('../pipeline').cssFilesToInject,
|
||||
'views/**/*.html': require('../pipeline').cssFilesToInject,
|
||||
'views/**/*.ejs': require('../pipeline').cssFilesToInject
|
||||
}
|
||||
},
|
||||
|
||||
devStylesBuild: {
|
||||
options: {
|
||||
startTag: '<!--STYLES-->',
|
||||
endTag: '<!--STYLES END-->',
|
||||
fileTmpl: '<link rel="stylesheet" href="%s">',
|
||||
appRoot: '.tmp/public',
|
||||
// relative: true
|
||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||
// (but be note that this can break custom font URLs)
|
||||
},
|
||||
|
||||
files: {
|
||||
'.tmp/public/**/*.html': require('../pipeline').cssFilesToInject,
|
||||
'views/**/*.html': require('../pipeline').cssFilesToInject,
|
||||
'views/**/*.ejs': require('../pipeline').cssFilesToInject
|
||||
}
|
||||
},
|
||||
|
||||
prodStyles: {
|
||||
options: {
|
||||
startTag: '<!--STYLES-->',
|
||||
endTag: '<!--STYLES END-->',
|
||||
fileTmpl: '<link rel="stylesheet" href="%s">',
|
||||
appRoot: '.tmp/public'
|
||||
},
|
||||
files: {
|
||||
'.tmp/public/index.html': ['.tmp/public/min/production.min.css'],
|
||||
'views/**/*.html': ['.tmp/public/min/production.min.css'],
|
||||
'views/**/*.ejs': ['.tmp/public/min/production.min.css']
|
||||
}
|
||||
},
|
||||
|
||||
prodStylesBuild: {
|
||||
options: {
|
||||
startTag: '<!--STYLES-->',
|
||||
endTag: '<!--STYLES END-->',
|
||||
fileTmpl: '<link rel="stylesheet" href="%s">',
|
||||
appRoot: '.tmp/public',
|
||||
// relative: true
|
||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||
// (but be note that this can break custom font URLs)
|
||||
},
|
||||
files: {
|
||||
'.tmp/public/index.html': ['.tmp/public/dist/*.css'],
|
||||
'views/**/*.html': ['.tmp/public/dist/*.css'],
|
||||
'views/**/*.ejs': ['.tmp/public/dist/*.css']
|
||||
}
|
||||
},
|
||||
|
||||
});//</ grunt.config.set() >
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-sails-linker --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-sails-linker');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
49
tasks/config/sync.js
Normal file
49
tasks/config/sync.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* `tasks/config/sync`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Synchronize files from the `assets` folder to `.tmp/public`,
|
||||
* smashing anything that's already there.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/sync.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('sync', {
|
||||
dev: {
|
||||
files: [{
|
||||
cwd: './assets',
|
||||
src: ['**/*.!(coffee|less)'],
|
||||
dest: '.tmp/public'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-sync --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-sync');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
64
tasks/config/uglify.js
Normal file
64
tasks/config/uglify.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* `tasks/config/uglify`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Minify client-side JavaScript files using UglifyES.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/uglify.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('uglify', {
|
||||
dist: {
|
||||
src: ['.tmp/public/concat/production.js'],
|
||||
dest: '.tmp/public/min/production.min.js'
|
||||
},
|
||||
options: {
|
||||
mangle: {
|
||||
reserved: [
|
||||
'AsyncFunction',
|
||||
'SailsSocket',
|
||||
'Promise',
|
||||
'File',
|
||||
'FileList',
|
||||
'FormData',
|
||||
'Location',
|
||||
'RttcRefPlaceholder',
|
||||
],
|
||||
keep_fnames: true//eslint-disable-line
|
||||
},
|
||||
compress: {
|
||||
keep_fnames: true//eslint-disable-line
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-uglify --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
||||
|
56
tasks/config/watch.js
Normal file
56
tasks/config/watch.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* `tasks/config/watch`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Run predefined tasks whenever certain files are added, changed or deleted.
|
||||
*
|
||||
* For more information, see:
|
||||
* https://sailsjs.com/anatomy/tasks/config/watch.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.config.set('watch', {
|
||||
assets: {
|
||||
|
||||
// Assets to watch:
|
||||
files: [
|
||||
'assets/**/*',
|
||||
'tasks/pipeline.js',
|
||||
'!**/node_modules/**'
|
||||
],
|
||||
|
||||
// When assets are changed:
|
||||
tasks: [
|
||||
'syncAssets',
|
||||
'linkAssets'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||
// so it's already been automatically loaded for you at this point.
|
||||
//
|
||||
// Of course, you can always remove this Grunt plugin altogether by
|
||||
// deleting this file. But check this out: you can also use your
|
||||
// _own_ custom version of this Grunt plugin.
|
||||
//
|
||||
// Here's how:
|
||||
//
|
||||
// 1. Install it as a local dependency of your Sails app:
|
||||
// ```
|
||||
// $ npm install grunt-contrib-watch --save-dev --save-exact
|
||||
// ```
|
||||
//
|
||||
//
|
||||
// 2. Then uncomment the following code:
|
||||
//
|
||||
// ```
|
||||
// // Load Grunt plugin from the node_modules/ folder.
|
||||
// grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
Reference in New Issue
Block a user