river-of-ebooks/tasks/config/sails-linker.js

217 lines
9.2 KiB
JavaScript
Raw Normal View History

2018-10-16 01:45:37 +00:00
/**
* `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) {
2018-10-16 01:45:37 +00:00
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'
2018-10-16 01:45:37 +00:00
// 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'
2018-10-16 01:45:37 +00:00
// 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'
2018-10-16 01:45:37 +00:00
// 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'
2018-10-16 01:45:37 +00:00
// 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']
}
},
// ╔═╗╦═╗╔═╗╔═╗╔═╗╔╦╗╔═╗╦╦ ╔═╗╔╦╗ ╦ ╦╔╦╗╔╦╗╦ ╔╦╗╔═╗╔╦╗╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗
// ╠═╝╠╦╝║╣ ║ ║ ║║║║╠═╝║║ ║╣ ║║ ╠═╣ ║ ║║║║ ║ ║╣ ║║║╠═╝║ ╠═╣ ║ ║╣ ╚═╗
// ╩ ╩╚═╚═╝╚═╝╚═╝╩ ╩╩ ╩╩═╝╚═╝═╩╝ ╩ ╩ ╩ ╩ ╩╩═╝ ╩ ╚═╝╩ ╩╩ ╩═╝╩ ╩ ╩ ╚═╝╚═╝
// ┌─ ┌─┐┬ ┬┌─┐┌┐┌┌┬┐ ┌─┐┬┌┬┐┌─┐ ┬ ┌─┐┌┬┐┌─┐┌─┐┬ ┬ ┌┬┐┌─┐┌┬┐┌─┐┬ ┌─┐┌┬┐┌─┐┌─┐ ─┐
// │─── │ │ │├┤ │││ │───└─┐│ ││├┤ │ │ │ ││├─┤└─┐├─┤ │ ├┤ │││├─┘│ ├─┤ │ ├┤ └─┐ ───│
// └─ └─┘┴─┘┴└─┘┘└┘ ┴ └─┘┴─┴┘└─┘ ┴─┘└─┘─┴┘┴ ┴└─┘┴ ┴ ┴ └─┘┴ ┴┴ ┴─┘┴ ┴ ┴ └─┘└─┘ ─┘
clientSideTemplates: {
options: {
startTag: '<!--TEMPLATES-->',
endTag: '<!--TEMPLATES END-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/index.html': ['.tmp/public/jst.js'],
'views/**/*.html': ['.tmp/public/jst.js'],
'views/**/*.ejs': ['.tmp/public/jst.js']
}
},
clientSideTemplatesBuild: {
options: {
startTag: '<!--TEMPLATES-->',
endTag: '<!--TEMPLATES END-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: '.tmp/public'
2018-10-16 01:45:37 +00:00
// 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/jst.js'],
'views/**/*.html': ['.tmp/public/jst.js'],
'views/**/*.ejs': ['.tmp/public/jst.js']
}
}
2018-10-16 01:45:37 +00:00
})// </ grunt.config.set() >
2018-10-16 01:45:37 +00:00
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 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');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}