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