Aurelia アプリケーションを System.js + JSPM から Webpack に移植しようとしています。アプリには複数のエントリ html があります: index.html
、index2.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;
問題は次のとおりです。
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...
- 私の理解によると、エラーは
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 undefined
webpack:///webpack/bootstrap <hash>
モジュールが見つからないために発生したと思われるfrom 。
次に何を試すべきか完全に混乱しています。提案してください。