【问题标题】:A bit confused with factor-bundle and grunt-browserify与 factor-bundle 和 grunt-browserify 有点混淆
【发布时间】:2015-01-25 19:03:13
【问题描述】:

一个菜鸟问题——我想创建两个包——app_bundle.js 和landing_bundle.js。

它们都将共享 react 和其他一些文件,因此我认为将这些文件提取到不同的通用包中是个好主意。

我找到了 factor-bundle,但无法让它工作。这是我现在的配置:

browserify: {
  app: {
    files: {
      '<%= yeoman.tmp %>/scripts/app_bundle.js': ['<%= yeoman.tmp %>/scripts/app.js'],
      '<%= yeoman.tmp %>/scripts/landing_bundle.js': ['<%= yeoman.tmp %>/scripts/landing.js']
    },
    options: {
      watch: true,
      plugin: [
        ['factor-bundle', { o: [ '<%= yeoman.tmp %>/scripts/app_bundle.js', '<%= yeoman.tmp %>/scripts/landing_bundle.js'] }]
      ],
    }
  }
}

我运行它,没有错误,但不确定分解的捆绑包 js 实际在哪里,我认为它实际上并没有保存在任何地方。

我不明白的是,factor-bundle 将文件保存在哪里?我将如何指定呢?

【问题讨论】:

    标签: browserify grunt-browserify


    【解决方案1】:

    如果您仍在寻求这方面的帮助,以下是我在我目前正在开发的应用程序中设置它的方式。这应该会在 dist 目录中输出三个文件:app.js、landing.js 和 common.js。 common.js 应该包含 app.js 和landing.js 共有的所有内容。让我知道这是否有帮助——我对这些东西也很陌生。

    browserify: {
      app: {
        files: {
          'dist/scripts/common.js': [
            'src/scripts/app.js',
            'src/scripts/landing.js'
          ]
        },
        options: {
          watch: true,
          plugin: [
            ['factor-bundle', { o: [ 'dist/scripts/app.js', 'dist/scripts/landing.js'] }]
          ]
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 2014-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      相关资源
      最近更新 更多