forked from jungho/azure-ad-authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
67 lines (65 loc) · 2 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
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
//split out vendor libs into a separate .js file
//this is important for code splitting and optimized
//delivery to the browser
const VENDOR_LIBS = [
'axios',
'lodash',
'react',
'react-redux',
'react-dom',
'react-router',
'redux-form',
'redux'
]
module.exports = {
entry: {
bundle: path.join(__dirname, 'src/client/index.js'),
vendor: VENDOR_LIBS
},
output: {
path: path.join(__dirname, 'dist'),
//if the js changes the chunkhash value will
//change hence causing the browser to download
//the new .js file.
filename: '[name].[chunkhash].js'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
},
{
use: ['style-loader', 'css-loader'],
test: /\.css$/
}
]
},
plugins: [
//ensure common dependencies are extracted into the vendor.js file
//the manifest.js file will help the browser determine if the vendor.js file
//has changed
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
//injects the necessary script tags to reference the .js files into the
//index.html file
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/client/index.html')
}),
new webpack.DefinePlugin({
//sets process.env.NODE_ENV variable at the window scope.
//if set to 'production', react will execute in prod mode
//less error checking etc.
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new CopyWebpackPlugin([
{ from: path.join(__dirname, 'style') }
])
]
};