-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (96 loc) · 3.17 KB
/
webpack.config.js
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var helpers = require('./helpers');
module.exports =
{
entry:
{
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},
resolve:
{
extensions: ['.ts', '.js'],
alias: {
"@angular/upgrade/static": "@angular/upgrade/bundles/upgrade-static.umd.js"
}
},
output:
{
path: helpers.root('dist'),
publicPath: '/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
module:
{
rules:
[
{
test: /\.ts$/,
loaders:
[
{
loader: 'awesome-typescript-loader',
options:
{
configFileName: helpers.root('src', 'tsconfig.json')
}
},
{
loader: 'angular2-template-loader'
}
]
},
{
test: /\.html$/,
include: helpers.root('src'),
loader: 'html-loader'
},
// Global Styles: Just move the file into assets folder. Script Tag to be manually added to index.html
{
test: /\.(css)$/,
include: helpers.root('src/style'),
loader: 'file-loader?name=assets/styles/[name].[ext]'
},
// Component Styles: Bundle into app.css and ask webpack to add script tag into index.html
{
test: /\.(css)$/,
include: helpers.root('src/components'),
loaders:
[
'to-string-loader',
'css-loader'
]
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader?name=assets/[name].[ext]'
}
]
},
plugins:
[
// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/, helpers.root('./src'), { // location of your src
} // a map of your routes
),
new webpack.optimize.CommonsChunkPlugin(
{
name: ['app', 'vendor', 'polyfills']
}
),
new HtmlWebpackPlugin({ template: 'src/index.html' })
],
devtool: 'cheap-module-eval-source-map',
devServer:
{
inline: true,
port: 80,
historyApiFallback: true,
stats: 'minimal'
}
};