简体   繁体   English

早午餐配置:javascript文件排除* .min.js文件

[英]brunch config: javascript files exclude *.min.js files

I understand how brunch handles javascript files, combining them into individual output files: 我理解brunch如何处理javascript文件,将它们组合成单独的输出文件:

  files:
    javascripts:
      joinTo:
        'javascripts/app.js': /^app/
        'javascripts/vendor.js': /^vendor/
        'test/javascripts/test.js': /^test(\/|\\)(?!vendor)/
        'test/javascripts/test-vendor.js': /^test(\/|\\)(?=vendor)/

the 2nd line, for example, takes all the javascript files in the /vendor/ folder and makes the vendor.js 例如,第二行获取/ vendor /文件夹中的所有javascript文件并生成vendor.js

The Regex (/^vendor/) specifies a folder path correct? 正则表达式(/ ^ vendor /)指定文件夹路径是否正确? Any way to have the regex apply to the file names as well? 有任何方法让正则表达式也适用于文件名吗? For example if there was a jquery.js and a jquery.min.js, I just want the jquery.js file included. 例如,如果有jquery.js和jquery.min.js,我只想包含jquery.js文件。 Is this possible? 这可能吗?

You can use functions to test against paths. 您可以使用函数来测试路径。 With them stuff should be simple: 他们应该很简单:

joinTo:
  'javascripts/vendor.js': (path) ->
    /^vendor/.test(path) and not /\.min\.js$/.test(path)

You can give the paths to be ignored. 您可以指定要忽略的路径。 The regex should match complete path for files, filenames included. 正则表达式应匹配文件的完整路径,包括文件名。

paths:
  public: '../deploy'
  ignored: 'vendor/styles/bootstrap'
  test: 'spec'

ignored key: string, regExp, function or array of them. 忽略键:string,regExp,函数或它们的数组。 Will check against files that would be ignored by brunch compilator. 将检查brunch compilator会忽略的文件。

But as Amberlamps suggested you can give regex to exclude *.min.js files in the files . 但正如Amberlamps建议你可以给正则表达式排除文件中的* .min.js文件。

PS: Never tested it but in the docs somewhere it is mentioned /_spec\\.\\w+$/ matches for user_spec.js. PS:从来没有测试过,但是在文档的某个地方提到/ /_spec\\.\\w+$//_spec\\.\\w+$/匹配user_spec.js。

I have never used brunch before, but if it is using RegExp to find specific paths you can exclude *.min.js files using: 我之前从未使用过早午餐,但如果使用RegExp查找特定路径,则可以使用以下方法排除* .min.js文件:

/^((?!vendor\/.*\.min\.js).)*$/

I used following answer as reference: Regular expression to match string not containing a word? 我使用以下答案作为参考: 正则表达式匹配不包含单词的字符串?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM