-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.build.config.js
102 lines (101 loc) · 3.36 KB
/
webpack.build.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
var path = require('path');
var webpack = require('webpack');
var DefinePlugin = require('webpack/lib/DefinePlugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var ngtools = require('@ngtools/webpack');
module.exports = {
entry: {
bootstrap: [__dirname + '/src/main/webapp/bootstrap.ts'],
// shark: ['@ntesmail/shark-angular2'],
angular: ['@angular/core', '@angular/platform-browser', '@angular/common', '@angular/router', '@angular/http', '@angular/forms', '@ntesmail/shark-angular2'],
thirdparty: ['jquery'],
polyfill: ['zone.js/dist/zone', 'reflect-metadata'],
},
output: {
path: path.join(__dirname, 'build', 'client'),
filename: 'js/[name]-[hash:8].js',
chunkFilename: 'js/chunk-[id]-[hash:8].js',
publicPath: 'http://localhost:9001/'
},
module: {
rules: [
{
test: /\.ts$/,
loader: '@ngtools/webpack'
},
{
test: /\.html$/,
loader: 'html-loader',
include: path.join(__dirname, 'src/main/')
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
name: 'images/[name]-[hash:8].[ext]',
limit: 100
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
},
{
test: /\.scss$/,
exclude: [
path.join(__dirname, 'src/main/webapp/app')
],
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!sass-loader' })
},
{
test: /\.scss$/,
include: [
path.join(__dirname, 'src/main/webapp/app')
],
use: [
'to-string-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.ejs$/,
loader: 'ejs-loader'
}
]
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
new ProgressBarPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// comments: false,
// compress: {
// warnings: false
// }
// }),
new webpack.NoEmitOnErrorsPlugin(),
new DefinePlugin({
'ENV': '"prod"'
}),
new ExtractTextPlugin('css/[name]-[hash:8].css'),
new HtmlWebpackPlugin({
filename: 'index.html',
template: __dirname + '/src/main/webapp/index.ejs'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new webpack.optimize.CommonsChunkPlugin({
name: ['bootstrap', 'angular', 'thirdparty', 'polyfill']
}),
new ngtools.AotPlugin({
skipCodeGeneration: false, //默认false. false:使用AoT ; true:不使用AoT
tsConfigPath: path.join(__dirname, 'tsconfig.json')
})
]
}