1

我正在使用 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" ]   } };
4

1 回答 1

0

我认为您忘记指定输入模块angular2ionic2模块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...
    ],

    // ...
}
于 2016-01-03T17:29:30.727 回答