-
Notifications
You must be signed in to change notification settings - Fork 14
/
webpack.client.config.js
55 lines (51 loc) · 1.44 KB
/
webpack.client.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
const HTMLWebpackPlugin = require('html-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const path = require('path');
const webpack = require('webpack');
const srcPath = path.resolve(__dirname, 'src');
const distPath = path.resolve(__dirname, 'dist');
const plugins = [
new HTMLWebpackPlugin({
title: 'Get real playlists to share with Spotify',
template: path.resolve(__dirname, 'src/client/index.ejs'),
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
];
if (process.env.NODE_ENV === 'analyse') {
plugins.push(new BundleAnalyzerPlugin());
}
module.exports = {
context: srcPath,
target: 'web',
entry: {
client: `${srcPath}/client/index.js`,
vendor: ['react', 'react-dom', 'react-router-dom', 'redux', 'redux-saga', 'react-redux'],
},
output: {
path: distPath,
filename: '[name].js',
publicPath: '/assets/',
},
resolve: {
modules: ['node_modules', 'src'],
extensions: ['*', '.js', '.json'],
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: { compact: false },
},
],
},
plugins,
devtool: 'source-map',
};