-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.production.config.js
More file actions
135 lines (122 loc) · 3.25 KB
/
webpack.production.config.js
File metadata and controls
135 lines (122 loc) · 3.25 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// 임시로 만들었음, angular2-webpack-starter로 바꾸자
var sliceArgs = Function.prototype.call.bind(Array.prototype.slice);
var toString = Function.prototype.call.bind(Object.prototype.toString);
var webpack = require('webpack');
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
// Webpack Plugins
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var config = {
entry: {
'vendor': [
// Polyfills
'core-js/es6',
'core-js/es7/reflect',
'zone.js/dist/zone',
'zone.js/dist/long-stack-trace-zone',
// Angular2
'@angular/common',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/core',
'@angular/router',
'@angular/http',
// RxJS
'rxjs',
// Other
'angular2-jwt',
'lodash'
],
'app': [
'./src/index'
]
},
// Config for our build files
output: {
path: root('dist'),
filename: '/build/[name].js',
// filename: '[name].[hash].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
// publicPath: 'http://mycdn.com/'
},
resolve: {
root: __dirname,
extensions: [
'',
'.ts',
'.js',
'.json',
'.css',
'.html'
]
},
module: {
preLoaders: [{test: /\.ts(x?)$/, loader: 'tslint-loader'}],
loaders: [{
test: /\.ts$/,
loader: 'ts-loader',
query: {
'ignoreDiagnostics': [
2403, // 2403 -> Subsequent variable declarations
2300, // 2300 Duplicate identifier
2304, // 2304 Cannot find name
2374, // 2374 -> Duplicate number index signature
2375 // 2375 -> Duplicate string index signature
]
},
exclude: [ /\.spec\.ts$/, /\.e2e\.ts$/, /node_modules/ ]
},
// Support for *.json files.
{test: /\.json$/, loader: 'json-loader'},
// Support for CSS as raw text
{test: /\.css$/, loader: 'raw-loader'},
// support for .html as raw text
{test: /\.html$/, loader: 'raw-loader'},
],
noParse: [
/zone\.js\/dist\/.+/,
/reflect-metadata/,
/es(6|7)-.+/,
/.zone-microtask/,
/.long-stack-trace-zone/
]
},
plugins: [
new webpack.ProvidePlugin({
'angular': 'angular'
}),
new CleanWebpackPlugin(['dist', 'build'], {
// root: "./",
verbose: true,
dry: false
// exclude: ['src']
}),
new CommonsChunkPlugin({name: 'vendor', filename: 'build/vendor.js', minChunks: Infinity}),
new CommonsChunkPlugin({name: 'common', filename: 'build/common.js', minChunks: 2, chunks: ['app', 'vendor']}),
new CopyWebpackPlugin([
{from: 'src', to: 'src'},
{from: 'index.html'}
])
],
// Other module loader config
tslint: {
emitErrors: false,
failOnHint: false
},
resolveLoader: {
modulesDirectories: [
path.join(__dirname, 'node_modules')
]
}
};
function root(args) {
args = sliceArgs(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
function rootNode(args) {
args = sliceArgs(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}
module.exports = config;