[英]webpack 2 lazy loading
我有具有通用依賴項的動態導入模塊,並且我需要common.js和g.js(在此示例中),但是它不起作用,我有空的common。 怎么了? 我想與g.js通用
index.js
System.import("./d")
.then( (module) => {
});
System.import("./t")
.then( (module) => {
});
t.js
import "./g";
module.exports = {
x: 5
}
d.js
import "./g";
export function message() {
alert("msg")
}
webpack.config.js
module.exports = {
entry: {index: "./index.js"},
context: __dirname,
output: {
filename: "dist/[name].js"
},
resolve: {
modules: [
"bower_components",
path.resolve('./'),
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: `common`,
async: true
})
]
};
module.exports = {
entry: {index: "./index.js"},
context: __dirname,
output: {
filename: "dist/[name].js"
},
resolve: {
modules: [
"bower_components",
path.resolve('./'),
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
children: true,
async: true,
}))
]
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.