我正在使用ionic2 + angular2。我想将自己的代码放在一个文件中,并将所有库合并到另一个文件中。
问题是我自己的应用程序仍然包含库。
这是我的配置文件:
var path = require('path'); var webpack = require("webpack");
module.exports = { root: path.resolve('/'),
devtool: 'source-map',
entry: {
vendor:[path.normalize('es6-shim/es6-shim.min'),
'reflect-metadata',
'web-animations.min',
'zone.js/dist/zone-microtask',
'ionic-framework/ionic'
],
app: path.resolve('www/app/app.ts')
},
output: {
filename: '[name].js',
},
plugin:[
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename:
'vendor.js', minChunks: Infinity }),
],
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript',
query: {
'doTypeCheck': false
},
include: path.resolve('www/app'),
exclude: /node_modules/
},
{
test: /\.js$/,
include: path.resolve('node_modules/angular2'),
loader: 'strip-sourcemap'
},
{ test: /\.html$/, loader: 'raw-loader' },
],
noParse: [
/es6-shim/,
/reflect-metadata/,
/web-animations/,
/zone\.js(\/|\\)dist(\/|\\)zone-microtask/
] }, resolve: {
alias: {
'web-animations.min': path.normalize('ionic-framework/js/web-animations.min')
},
extensions: ["", ".ts", ".js" ] } };
答案 0 :(得分:0)
我认为您忘记为angular2
条目指定ionic2
和vendor
个模块:
entry: {
vendor:[
path.normalize('es6-shim/es6-shim.min'),
'reflect-metadata',
'web-animations.min',
'zone.js/dist/zone-microtask',
'ionic-framework/ionic',
// HERE: add all "angular2" and "ionic2" modules you're using
'angular2/platform/browser',
'angular2/core',
'angular2/router',
// and so on...
],
// ...
}