【问题标题】:Changing brunch's conventions.assets isn't doing what I expect改变早午餐的conventions.assets 并没有达到我的预期
【发布时间】:2017-08-13 05:37:33
【问题描述】:

我已经阅读了我能找到的所有相关文档,但我不知道出了什么问题。

我的文件结构是这样的:

project/
  brunch-config.js
  node_modules/
    ...
  package.json
  source/
    styles.css
    app.js
    index.html

现在我知道默认情况下所有资产都应该在app/assets 中,但我已将app/ 更改为source/,并且我想消除对source/assets 目录的需要。

因此,我的 brunch-config.js 文件如下所示:

exports.config = {
    paths: {
        public: 'build',
        watched: ['source']
    },
    conventions: {
        ignored: () => false,
        assets: '*.html'
    },
    files: {
        javascripts: {joinTo: 'app.js'},
        stylesheets: {joinTo: 'app.css'}
    }
};

所有工作都像我希望的那样处理资产。从我读过的所有内容来看,我认为将conventions.assets 默认的/assets\// 更改为'*.html' 会导致source 目录中的任何html 文件被视为资产。这不是正在发生的事情。

运行brunch watch --server 时,css 和js 文件被正确编译,但index.html 文件永远不会被复制。我是不是做错了什么或误解了早午餐应该如何工作?

【问题讨论】:

    标签: brunch


    【解决方案1】:

    使用正则表达式匹配所有 HTML 文件:assets: /\.html$/

    exports.config = {
        paths: {
            public: 'build',
            watched: ['source']
        },
        conventions: {
            ignored: () => false,
            assets: /\.html$/
        },
        files: {
            javascripts: {joinTo: 'app.js'},
            stylesheets: {joinTo: 'app.css'}
        }
    };
    

    【讨论】:

      猜你喜欢
      • 2016-11-19
      • 2014-09-24
      • 1970-01-01
      • 2018-08-27
      • 2016-01-19
      • 1970-01-01
      • 2015-09-03
      • 2019-01-04
      • 2018-05-07
      相关资源
      最近更新 更多