我正在尝试设置我的set应用程序来使用Browserify (它工作得很好)。然而,我不想让非浏览器序列化的文件自动注入我的网页。
在我的tasks/pipeline.js文件中,我尝试过这样做(需要浏览的js文件位于browserify目录中):
// Client-side javascript files to inject in order
// (uses Grunt-style wildcard/glob/splat expressions)
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js',
// Ignore browserify directory
'!js/browserify/**/*'
];然而,这是不工作的,我的非浏览器序列化的文件被注入到网页。我是航海新手,所以很可能这并不是实现这一目标的正确方法。如有任何建议,将不胜感激。
发布于 2015-03-29 10:01:40
它实际上相当容易,只是不把**放在那里。**通配符意味着递归搜索。我要做的是:
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/*.js', //all files directly in .js folder will be included, but any folders not specified above will not
];然后,如果在js目录中添加了一个您实际上想要包含的文件夹,只需确保在依赖项和最后一行之间指定该文件夹,如
'js/folderIWantToInclude/**/*.js'不要忘记,这会将所有文件复制到.tmp中,有时您需要手动清除它,这样的更改才能生效。我还建议您访问格朗特配置文件文档,以供参考--是grunt做的,而不是帆。
发布于 2015-11-02 20:48:52
您可以使用" exclude“(!)排除文件。操作人员如下:
var cssFilesToInject = [
'styles/**/*.css',
'!styles/ie8.css',
'!styles/ie9.css'
];
// Client-side javascript files to inject in order
// (uses Grunt-style wildcard/glob/splat expressions)
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js',
"!js/dependencies/respond/respond.src.js",
];发布于 2015-09-28 17:30:11
您可以通过快速修复使其按自己的方式工作:在pipeline.js的末尾,替换以下代码块:
module.exports.cssFilesToInject = cssFilesToInject.map(function(path) {
return '.tmp/public/' + path;
});
module.exports.jsFilesToInject = jsFilesToInject.map(function(path) {
return '.tmp/public/' + path;
});
module.exports.templateFilesToInject = templateFilesToInject.map(function(path) {
return 'assets/' + path;
});使用
module.exports.cssFilesToInject = cssFilesToInject.map(function(path) {
var tmpPath = '.tmp/public/';
if (path.substring(0,1) == '!')
return '!' + tmpPath + path.substring(1);
return tmpPath + path;
});
module.exports.jsFilesToInject = jsFilesToInject.map(function(path) {
var tmpPath = '.tmp/public/';
if (path.substring(0,1) == '!')
return '!' + tmpPath + path.substring(1);
return tmpPath + path;
});
module.exports.templateFilesToInject = templateFilesToInject.map(function(path) {
var tmpPath = 'assets/';
if (path.substring(0,1) == '!')
return '!' + tmpPath + path.substring(1);
return tmpPath + path;
});如您所见,原始代码将tmp文件夹的相对路径添加到给定的规则中,从而使!位于最终路径的中间位置。看我对一个非常相似的问题的回答的完整解释。
https://stackoverflow.com/questions/29327025
复制相似问题