-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
63 lines (62 loc) · 1.54 KB
/
webpack.config.js
File metadata and controls
63 lines (62 loc) · 1.54 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
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpackConfig = {
devtool: 'inline-source-map',
entry: {
'vendor': ['./src/vendor.ts'],
'main': './src/main.ts'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'assets')
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
use: 'awesome-typescript-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" }
]
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['main', 'vendor'],
filename: 'assets/[name].js'
}),
new HtmlWebpackPlugin({
// chunks: ['vendors', 'assets/main'],
filename: 'views/index.html',
template: path.join(__dirname, './src/views/index.html')
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
}
if (process.env.NODE_ENV === 'development') {
// webpackConfig.entry.vendor.push('webpack-hot-middleware/client')
// webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin())
}
if (process.env.NODE_ENV === 'production') {
webpackConfig.output.path = path.resolve(__dirname, '.')
webpackConfig.plugins.push(
new webpack.optimize.UglifyJsPlugin({
comments: false,
sourceMap: true,
compress: true
})
)
}
module.exports = webpackConfig