Mercurial > hg > ng2-query-ismi
comparison config/webpack.common.js @ 60:7b9d616695d3 webpack
new setup using webpack (and Angular 4).
author | casties |
---|---|
date | Wed, 29 Mar 2017 20:58:57 +0200 |
parents | |
children | 7787ca310644 |
comparison
equal
deleted
inserted
replaced
59:0d51fefdbae6 | 60:7b9d616695d3 |
---|---|
1 var webpack = require('webpack'); | |
2 var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
3 var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
4 var helpers = require('./helpers'); | |
5 | |
6 module.exports = { | |
7 entry: { | |
8 'polyfills': './src/polyfills.ts', | |
9 'vendor': './src/vendor.ts', | |
10 'app': './src/main.ts' | |
11 }, | |
12 | |
13 resolve: { | |
14 extensions: ['.ts', '.js'] | |
15 }, | |
16 | |
17 module: { | |
18 rules: [ | |
19 { | |
20 test: /\.ts$/, | |
21 loaders: [ | |
22 { | |
23 loader: 'awesome-typescript-loader', | |
24 options: { configFileName: helpers.root('src', 'tsconfig.json') } | |
25 } , 'angular2-template-loader' | |
26 ] | |
27 }, | |
28 { | |
29 test: /\.html$/, | |
30 loader: 'html-loader' | |
31 }, | |
32 { | |
33 test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/, | |
34 loader: 'file-loader?name=assets/[name].[hash].[ext]' | |
35 }, | |
36 { | |
37 test: /\.css$/, | |
38 exclude: helpers.root('src', 'app'), | |
39 loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' }) | |
40 }, | |
41 { | |
42 test: /\.css$/, | |
43 include: helpers.root('src', 'app'), | |
44 loader: 'raw-loader' | |
45 } | |
46 ] | |
47 }, | |
48 | |
49 plugins: [ | |
50 // Workaround for angular/angular#11580 | |
51 new webpack.ContextReplacementPlugin( | |
52 // The (\\|\/) piece accounts for path separators in *nix and Windows | |
53 /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, | |
54 helpers.root('./src'), // location of your src | |
55 {} // a map of your routes | |
56 ), | |
57 | |
58 new webpack.optimize.CommonsChunkPlugin({ | |
59 name: ['app', 'vendor', 'polyfills'] | |
60 }), | |
61 | |
62 new HtmlWebpackPlugin({ | |
63 template: 'src/index.html' | |
64 }) | |
65 ] | |
66 }; |