-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
81 lines (75 loc) · 1.93 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
const autoPrefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
var BUILD_DIR = path.resolve(__dirname, 'dist');
var APP_DIR = path.resolve(__dirname, 'src/client/app');
const layoutLoaders = [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [
autoPrefixer({
browsers: 'last 3 versions'
})
]
}
}
];
var config = {
bail: true,
entry: APP_DIR + '/index.js',
output: {
filename: 'js/[hash].bundle.js',
path: BUILD_DIR
},
module: {
rules: [
{
test: /\.js?/,
loader: 'babel-loader',
include: APP_DIR
}, {
test: /\.json$/,
loader: 'json-loader'
}, {
test: /\.css$/,
use: layoutLoaders
},
{
test: /\.s?css$/,
use: layoutLoaders.concat(['sass-loader'])
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new UglifyJSPlugin({ uglifyOptions: { compress: { warnings: false, comparisons: false } } }),
new HtmlWebpackPlugin({
favicon: 'dist/favicon.ico',
filename: `index.html`,
template: 'src/index.template.html',
title: 'Watson Workspace - Diagnostics',
inject: 'body'
})
],
resolve: {
alias: {
_app: path.resolve(__dirname, 'src/client/app'),
_comms: path.resolve(__dirname, 'src/client/app/comms'),
_components: path.resolve(__dirname, 'src/client/app/components'),
_containers: path.resolve(__dirname, 'src/client/app/containers'),
_data: path.resolve(__dirname, 'src/client/app/data'),
_sass: path.resolve(__dirname, 'src/client/sass')
}
}
};
console.log('*** BUILD WEBPACK ***');
module.exports = config;