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');
|
||||
// ```
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
};
|
158
tasks/pipeline.js
Normal file
158
tasks/pipeline.js
Normal file
@ -0,0 +1,158 @@
|
||||
/**
|
||||
* tasks/pipeline.js
|
||||
*
|
||||
* The order in which your CSS, JavaScript, and client-side template files
|
||||
* injected as <script> or <link> tags.
|
||||
*
|
||||
* > If you are not relying on automatic asset linking, then you can safely ignore this file.
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/pipeline.js
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// ██████╗ ██╗ █████╗ ██╗███╗ ██╗ ██████╗███████╗███████╗
|
||||
// ██╔══██╗██║ ██╔══██╗██║████╗ ██║ ██╔════╝██╔════╝██╔════╝
|
||||
// ██████╔╝██║ ███████║██║██╔██╗ ██║ ██║ ███████╗███████╗
|
||||
// ██╔═══╝ ██║ ██╔══██║██║██║╚██╗██║ ██║ ╚════██║╚════██║
|
||||
// ██║ ███████╗██║ ██║██║██║ ╚████║ ██╗╚██████╗███████║███████║
|
||||
// ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝╚══════╝╚══════╝
|
||||
//
|
||||
// ███████╗██╗██╗ ███████╗███████╗
|
||||
// ██╔════╝██║██║ ██╔════╝██╔════╝
|
||||
// █████╗ ██║██║ █████╗ ███████╗
|
||||
// ██╔══╝ ██║██║ ██╔══╝ ╚════██║
|
||||
// ██║ ██║███████╗███████╗███████║
|
||||
// ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
|
||||
//
|
||||
// CSS files to inject as <link> tags, in order.
|
||||
//
|
||||
// > Note: if you're using built-in LESS support with default settings,
|
||||
// > you'll want to change `assets/styles/importer.less` instead.
|
||||
//
|
||||
var cssFilesToInject = [
|
||||
|
||||
// Bring in `.css` files for themes and style guides (e.g. Bootstrap, Foundation)
|
||||
'dependencies/**/*.css',
|
||||
|
||||
// All of the rest of your custom `.css` files will be injected here,
|
||||
// in no particular order. To customize the ordering, add additional
|
||||
// items here, _above_ this one.
|
||||
'styles/**/*.css'
|
||||
];
|
||||
|
||||
|
||||
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
|
||||
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
|
||||
// ██║ ██║ ██║█████╗ ██╔██╗ ██║ ██║█████╗███████╗██║██║ ██║█████╗
|
||||
// ██║ ██║ ██║██╔══╝ ██║╚██╗██║ ██║╚════╝╚════██║██║██║ ██║██╔══╝
|
||||
// ╚██████╗███████╗██║███████╗██║ ╚████║ ██║ ███████║██║██████╔╝███████╗
|
||||
// ╚═════╝╚══════╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
|
||||
//
|
||||
// ██╗███████╗ ███████╗██╗██╗ ███████╗███████╗
|
||||
// ██║██╔════╝ ██╔════╝██║██║ ██╔════╝██╔════╝
|
||||
// ██║███████╗ █████╗ ██║██║ █████╗ ███████╗
|
||||
// ██ ██║╚════██║ ██╔══╝ ██║██║ ██╔══╝ ╚════██║
|
||||
// ██╗╚█████╔╝███████║ ██║ ██║███████╗███████╗███████║
|
||||
// ╚═╝ ╚════╝ ╚══════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
|
||||
//
|
||||
// Client-side javascript files to inject as <script> tags, in order.
|
||||
//
|
||||
var jsFilesToInject = [
|
||||
|
||||
// Load `sails.io` before everything else.
|
||||
'dependencies/sails.io.js',
|
||||
|
||||
// Bring in `.js` files for any other client-side JavaScript dependencies.
|
||||
// (e.g. Lodash, Vue.js, jQuery, Bootstrap, Ember, Angular, etc.)
|
||||
// > Be sure to list dependencies that depend on each other in the right order!
|
||||
'dependencies/lodash.js',
|
||||
'dependencies/jquery.min.js',
|
||||
'dependencies/vue.js',
|
||||
'dependencies/vue-router.js',
|
||||
'dependencies/**/*.js',
|
||||
|
||||
// First amongst the app-level files, bring in cloud configuration
|
||||
'js/cloud.setup.js',
|
||||
|
||||
// Bring in components & utilities before bringing in the rest (i.e. page scripts)
|
||||
'js/components/**/*.js',
|
||||
'js/utilities/**/*.js',
|
||||
|
||||
// All of the rest of your custom client-side js files will be injected here,
|
||||
// in no particular order. To customize the ordering, add additional items
|
||||
// here, _above_ this one.
|
||||
'js/**/*.js'
|
||||
];
|
||||
|
||||
|
||||
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
|
||||
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
|
||||
// ██║ ██║ ██║█████╗ ██╔██╗ ██║ ██║█████╗███████╗██║██║ ██║█████╗
|
||||
// ██║ ██║ ██║██╔══╝ ██║╚██╗██║ ██║╚════╝╚════██║██║██║ ██║██╔══╝
|
||||
// ╚██████╗███████╗██║███████╗██║ ╚████║ ██║ ███████║██║██████╔╝███████╗
|
||||
// ╚═════╝╚══════╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
|
||||
//
|
||||
// ████████╗███████╗███╗ ███╗██████╗ ██╗ █████╗ ████████╗███████╗███████╗
|
||||
// ╚══██╔══╝██╔════╝████╗ ████║██╔══██╗██║ ██╔══██╗╚══██╔══╝██╔════╝██╔════╝
|
||||
// ██║ █████╗ ██╔████╔██║██████╔╝██║ ███████║ ██║ █████╗ ███████╗
|
||||
// ██║ ██╔══╝ ██║╚██╔╝██║██╔═══╝ ██║ ██╔══██║ ██║ ██╔══╝ ╚════██║
|
||||
// ██║ ███████╗██║ ╚═╝ ██║██║ ███████╗██║ ██║ ██║ ███████╗███████║
|
||||
// ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝
|
||||
//
|
||||
// Client-side HTML templates to precompile and inject as a single <script> tag.
|
||||
// (The ordering of this array shouldn't matter.)
|
||||
//
|
||||
// > By default, Sails uses JST (~=lodash/underscore) templates and precompiles
|
||||
// > them into functions for you. If you want to use handlebars, pug, dust, etc.,
|
||||
// > with the asset linker, no problem-- you'll just want to make sure the precompiled
|
||||
// > templates get spit out to the same file. For information on customizing and
|
||||
// > installing your own Grunt tasks or using a different build pipeline, be sure
|
||||
// > to check out:
|
||||
// > https://sailsjs.com/docs/concepts/assets/task-automation
|
||||
//
|
||||
var templateFilesToInject = [
|
||||
'templates/**/*.html'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// ███╗ ███╗██╗███████╗ ██████╗ ███████╗███████╗████████╗██╗ ██╗██████╗
|
||||
// ████╗ ████║██║██╔════╝██╔════╝ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
|
||||
// ██╔████╔██║██║███████╗██║ ███████╗█████╗ ██║ ██║ ██║██████╔╝
|
||||
// ██║╚██╔╝██║██║╚════██║██║ ╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
|
||||
// ██║ ╚═╝ ██║██║███████║╚██████╗██╗ ███████║███████╗ ██║ ╚██████╔╝██║
|
||||
// ╚═╝ ╚═╝╚═╝╚══════╝ ╚═════╝╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
//
|
||||
// The following code exists to parse the arrays of glob expressions above, and
|
||||
// then expose them via `module.exports`. **You should not need to change any of
|
||||
// the code below, unless you are modifying the default asset pipeline.**
|
||||
|
||||
// Default path for public folder (see documentation on sailsjs.com for more information)
|
||||
var tmpPath = '.tmp/public/';
|
||||
|
||||
// Prefix relative paths to source files so they point to the proper locations
|
||||
// (i.e. where the other Grunt tasks spit them out, or in some cases, where
|
||||
// they reside in the first place)
|
||||
module.exports.cssFilesToInject = cssFilesToInject.map((cssPath)=>{
|
||||
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
||||
if (cssPath[0] === '!') {
|
||||
return require('path').join('!' + tmpPath, cssPath.substr(1));
|
||||
}
|
||||
return require('path').join(tmpPath, cssPath);
|
||||
});
|
||||
module.exports.jsFilesToInject = jsFilesToInject.map((jsPath)=>{
|
||||
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
||||
if (jsPath[0] === '!') {
|
||||
return require('path').join('!' + tmpPath, jsPath.substr(1));
|
||||
}
|
||||
return require('path').join(tmpPath, jsPath);
|
||||
});
|
||||
module.exports.templateFilesToInject = templateFilesToInject.map((tplPath)=>{
|
||||
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
||||
if (tplPath[0] === '!') {
|
||||
return require('path').join('!assets/', tplPath.substr(1));
|
||||
}
|
||||
return require('path').join('assets/', tplPath);
|
||||
});
|
22
tasks/register/build.js
Normal file
22
tasks/register/build.js
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* `tasks/register/build.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This Grunt tasklist will be executed if you run `sails www` or
|
||||
* `grunt build` in a development environment.
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/build.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('build', [
|
||||
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||
'compileAssets',
|
||||
// 'babel', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||
'linkAssetsBuild',
|
||||
'clean:build',
|
||||
'copy:build'
|
||||
]);
|
||||
};
|
30
tasks/register/buildProd.js
Normal file
30
tasks/register/buildProd.js
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* `tasks/register/buildProd.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This Grunt tasklist will be executed instead of `build` if you
|
||||
* run `sails www` in a production environment, e.g.:
|
||||
* `NODE_ENV=production sails www`
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/build-prod.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('buildProd', [
|
||||
'polyfill:prod', //« Remove this to skip transpilation in production (not recommended)
|
||||
'compileAssets',
|
||||
'babel', //« Remove this to skip transpilation in production (not recommended)
|
||||
'concat',
|
||||
'uglify',
|
||||
'cssmin',
|
||||
'hash',//« Cache-busting
|
||||
'copy:beforeLinkBuildProd',//« For prettier URLs after cache-busting
|
||||
'linkAssetsBuildProd',
|
||||
'clean:build',
|
||||
'copy:build',
|
||||
'clean:afterBuildProd'
|
||||
]);
|
||||
};
|
||||
|
16
tasks/register/compileAssets.js
Normal file
16
tasks/register/compileAssets.js
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* `tasks/register/compileAssets.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/compile-assets.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('compileAssets', [
|
||||
'clean:dev',
|
||||
'less:dev',
|
||||
'copy:dev',
|
||||
]);
|
||||
};
|
27
tasks/register/default.js
Normal file
27
tasks/register/default.js
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* `tasks/register/default.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This is the default Grunt tasklist that will be executed if you
|
||||
* run `grunt` in the top level directory of your app. It is also
|
||||
* called automatically when you start Sails in development mode using
|
||||
* `sails lift` or `node app` in a development environment.
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/default.js
|
||||
*
|
||||
*/
|
||||
module.exports = function (grunt) {
|
||||
|
||||
|
||||
grunt.registerTask('default', [
|
||||
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||
'compileAssets',
|
||||
// 'babel', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||
'linkAssets',
|
||||
'watch'
|
||||
]);
|
||||
|
||||
|
||||
};
|
15
tasks/register/linkAssets.js
Normal file
15
tasks/register/linkAssets.js
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* `tasks/register/linkAssets.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/link-assets.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('linkAssets', [
|
||||
'sails-linker:devJs',
|
||||
'sails-linker:devStyles',
|
||||
]);
|
||||
};
|
15
tasks/register/linkAssetsBuild.js
Normal file
15
tasks/register/linkAssetsBuild.js
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* `tasks/register/linkAssetsBuild.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/link-assets-build.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('linkAssetsBuild', [
|
||||
'sails-linker:devJsBuild',
|
||||
'sails-linker:devStylesBuild',
|
||||
]);
|
||||
};
|
15
tasks/register/linkAssetsBuildProd.js
Normal file
15
tasks/register/linkAssetsBuildProd.js
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* `tasks/register/linkAssetsBuildProd.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/link-assets-build-prod.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('linkAssetsBuildProd', [
|
||||
'sails-linker:prodJsBuild',
|
||||
'sails-linker:prodStylesBuild',
|
||||
]);
|
||||
};
|
28
tasks/register/polyfill.js
Normal file
28
tasks/register/polyfill.js
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* `tasks/register/polyfill.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/polyfill.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('polyfill:prod', 'Add the polyfill file to the top of the list of files to concatenate', ()=>{
|
||||
grunt.config.set('concat.js.src', [require('sails-hook-grunt/accessible/babel-polyfill')].concat(grunt.config.get('concat.js.src')));
|
||||
});
|
||||
grunt.registerTask('polyfill:dev', 'Add the polyfill file to the top of the list of files to copy and link', ()=>{
|
||||
grunt.config.set('copy.dev.files', grunt.config.get('copy.dev.files').concat({
|
||||
expand: true,
|
||||
cwd: require('path').dirname(require('sails-hook-grunt/accessible/babel-polyfill')),
|
||||
src: require('path').basename(require('sails-hook-grunt/accessible/babel-polyfill')),
|
||||
dest: '.tmp/public/polyfill'
|
||||
}));
|
||||
var devLinkFiles = grunt.config.get('sails-linker.devJs.files');
|
||||
grunt.config.set('sails-linker.devJs.files', Object.keys(devLinkFiles).reduce((linkerConfigSoFar, glob)=>{
|
||||
linkerConfigSoFar[glob] = ['.tmp/public/polyfill/polyfill.min.js'].concat(devLinkFiles[glob]);
|
||||
return linkerConfigSoFar;
|
||||
}, {}));
|
||||
});
|
||||
};
|
||||
|
26
tasks/register/prod.js
Normal file
26
tasks/register/prod.js
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* `tasks/register/prod.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This Grunt tasklist will be executed instead of `default` when
|
||||
* your Sails app is lifted in a production environment (e.g. using
|
||||
* `NODE_ENV=production node app`).
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/prod.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('prod', [
|
||||
'polyfill:prod', //« Remove this to skip transpilation in production (not recommended)
|
||||
'compileAssets',
|
||||
'babel', //« Remove this to skip transpilation in production (not recommended)
|
||||
'concat',
|
||||
'uglify',
|
||||
'cssmin',
|
||||
'sails-linker:prodJs',
|
||||
'sails-linker:prodStyles',
|
||||
]);
|
||||
};
|
||||
|
15
tasks/register/syncAssets.js
Normal file
15
tasks/register/syncAssets.js
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* `tasks/register/syncAssets.js`
|
||||
*
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* For more information see:
|
||||
* https://sailsjs.com/anatomy/tasks/register/sync-assets.js
|
||||
*
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('syncAssets', [
|
||||
'less:dev',
|
||||
'sync:dev',
|
||||
]);
|
||||
};
|
Reference in New Issue
Block a user