1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| 'use strict';
const path = require("path"); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const basePlugins = [ new webpack.optimize.CommonsChunkPlugin('vendor', '[name].[hash].bundle.js'),
new HtmlWebpackPlugin({ template: './src/index.html', inject: 'body', minify: false }) ];
const envPlugins = { production: [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ], development: [] };
const plugins = basePlugins.concat(envPlugins[process.env.NODE_ENV] || []);
module.exports = { entry: { app: './src/index.ts', vendor: [ '@angular/core', '@angular/compiler', '@angular/common', '@angular/http', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', 'es6-shim', 'redux', 'redux-thunk', 'redux-logger', 'reflect-metadata', 'ng2-redux', 'zone.js', ] },
output: { path: path.resolve(__dirname, 'dist'), filename: '[name].[hash].js', publicPath: "/", sourceMapFilename: '[name].[hash].js.map' },
devtool: 'source-map',
resolve: { extensions: ['.webpack.js', '.web.js', '.ts', '.js'] },
plugins: plugins,
module: { rules: [ { test: /\.ts$/, loader: 'tslint' }, { test: /\.ts$/, loader: 'ts', exclude: /node_modules/ }, { test: /\.html$/, loader: 'raw' }, { test: /\.css$/, loader: 'style!css?sourceMap' }, { test: /\.svg/, loader: 'url' }, { test: /\.eot/, loader: 'url' }, { test: /\.woff/, loader: 'url' }, { test: /\.woff2/, loader: 'url' }, { test: /\.ttf/, loader: 'url' }, ], noParse: [ /zone\.js\/dist\/.+/, /angular2\/bundles\/.+/ ] } }
|