2

Aurelia アプリケーションを System.js + JSPM から Webpack に移植しようとしています。アプリには複数のエントリ html があります: index.htmlindex2.html

私は Webpack を初めて使用するので、 easy-webpack を使用して aurelia スケルトンから始め、アプリケーション固有のコードを徐々に追加しようとしました。

単一エントリの最も基本的なケースでindex.htmlは、スケルトンは非常にうまく機能しました。また、ローカル モジュールを として追加node_modulesし、同じものを で使用しましたapp

ただし、複数のエントリの html の構成を適切にセットアップできません。これは私のwebpack.config.js(変更された部分を示す)のようです:

const baseConfig = {
  entry: {
    'app': [/* this is filled by the aurelia-webpack-plugin */],
    'aurelia-bootstrap': coreBundles.bootstrap,
    'aurelia': coreBundles.aurelia.filter(pkg => coreBundles.bootstrap.indexOf(pkg) === -1),
    'some-common-script': path.resolve('src/some-common-script.js'),
    'index1-script': path.resolve('src/index1-script'), //needed exclusively in index.html
    'index2-script': path.resolve('src/index2-script') //needed exclusively in index2.html
  }, ...
 };

switch (ENV) {
  ...
  default:
  case 'development':
    process.env.NODE_ENV = 'development';
    config = generateConfig(
      baseConfig,
      ...
      require('@easy-webpack/config-common-chunks-simple')
       ({ appChunkName: 'app', firstChunk: 'aurelia-bootstrap' }),      
      require('@easy-webpack/config-generate-index-html')
       ({ minify: false, overrideOptions: { excludeChunks: ["index2-script"] } }),
      require('@easy-webpack/config-generate-index-html')
       ({
         minify: false, overrideOptions: {
         chunks: ['some-common-script', 'index2-script'],
         filename: 'index2.html',
         template: 'index2.html',
         }
      }),...
    );
    break;
}

module.exports = config;

問題は次のとおりです。

  1. index2-scriptデフォルトから除外するconfig-generate-index-htmlと、スクリプトが追加される順序がではなく にindex.htmlなり、原因になります。app.bundle.js, aurelia-bootstrap.bundle.js, ...aurelia-bootstrap.bundle.js, app.bundle.js, ...Uncaught ReferenceError: webpackJsonp is not defined...
  2. 私の理解によると、エラーはeasy-webpack/config-common-chunks-simple(ラッパーアラウンドwebpack.optimize.CommonsChunkPlugin)が初期コードと共通コードをaurelia-bootstrap.bundle.js(「ブートストラップ」チャンク)にパックしたために発生します。したがって、私もなしで試しrequire('@easy-webpack/config-common-chunks-simple')({ appChunkName: 'app', firstChunk: 'aurelia-bootstrap' })ましたが、代わりに得ました
    • Uncaught TypeError: Reflect.getOwnMetadata is not a functionからaurelia-metadata.js、そして
    • Uncaught TypeError: Cannot read property 'call' of undefinedwebpack:///webpack/bootstrap <hash>モジュールが見つからないために発生したと思われるfrom 。

次に何を試すべきか完全に混乱しています。提案してください。

4

0 に答える 0