-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.prod.config.js
119 lines (113 loc) · 3.63 KB
/
webpack.prod.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
112
113
114
115
116
117
118
119
'use strict';
const AotPlugin = require('@ngtools/webpack').AotPlugin;
const webpack = require('webpack');
const path = require('path');
const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
entry: {
polyfills: path.resolve(__dirname, 'app/polyfills.ts'),
vendor: path.resolve(__dirname, 'app/vendor.ts'),
main: path.resolve(__dirname, 'app/main.aot.ts')
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].min.js'
},
module: {
rules: [
{
test: /\.ts$/,
loader: '@ngtools/webpack'
},
{
test: /\.html$/,
use: 'raw-loader'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader'
}),
include: path.resolve(__dirname, 'app/public/styles')
},
{
test: /\.css$/,
loader: 'raw-loader',
exclude: path.resolve(__dirname, 'app/public/styles')
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader?name=fonts/[name].[hash].[ext]?'
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
path.resolve(__dirname, 'app')
),
new webpack.LoaderOptionsPlugin({
options: {
tslint: {
emitErrors: false,
failOnHint: false
}
}
}),
new AotPlugin({
tsConfigPath: path.resolve(__dirname, 'tsconfig.prod.json'),
entryModule: path.resolve(__dirname, 'app/app.module#AppModule')
}),
new CommonsChunkPlugin({
name: ['vendor', 'polyfills']
}),
new ExtractTextPlugin('[name].css'),
new OptimizeCssAssetsPlugin({
cssProcessorOptions: {
discardComments: {
removeAll: true
}
}
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'app/public/index.html'),
chunksSortMode: 'dependency',
minify: {
caseSensitive: true,
collapseWhitespace: true,
removeComments: true
}
}),
new ScriptExtHtmlWebpackPlugin({
inline: [/\.js$/]
}),
new StyleExtHtmlWebpackPlugin(),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: true },
output: { comments: false },
sourceMap: false
})
],
resolve: {
modules: [
'node_modules',
path.resolve(__dirname, 'app')
],
extensions: ['.ts', '.js', '.html', 'css', 'json']
},
devtool: false
};