0

a bit of a noob question -- I'd like to create two bundles -- app_bundle.js, and landing_bundle.js.

They will both share react, and a few other files, so I thought it would be a good idea to extract those out into a different, common bundle.

I found factor-bundle, but am having trouble getting it to work. This is what my config looks like for now:

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'] }]
      ],
    }
  }
}

I ran it, got no errors, but am not sure where the factored bundle js actually is, I think it didn't actually save anywhere.

The thing I'm not understanding is, where will factor-bundle save the file? how would I go about specifying that?

4

1 回答 1

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'] }]
      ]
    }
  }
}
于 2015-03-06T17:57:45.617 回答