-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
80 lines (77 loc) · 1.92 KB
/
webpack.common.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
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
main: path.join(__dirname, 'src', 'index.jsx'),
react: ['react', 'react-dom'],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
alias: {
'@todomvc': path.resolve('src'),
},
},
module: {
rules: [
{
// this is so that we can compile any React,
// ES6 and above into normal ES5 syntax
test: /\.(js|jsx)$/,
resolve: {
extensions: ['.js', '.jsx'],
},
// we do not want anything from node_modules to be compiled
exclude: /node_modules/,
use: ['babel-loader?cacheDirectory=true'],
},
{
test: /\.(css)$/,
use: [
'style-loader', // creates style nodes from JS strings
'css-loader', // translates CSS into CommonJS
],
},
{
test: /\.(jpg|jpeg|png|gif|mp3)$/,
loaders: ['file-loader'],
},
{
test: /\.svg$/,
loader: 'svg-inline-loader',
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
],
},
plugins: [
new webpack.ProgressPlugin(),
new CleanWebpackPlugin(),
new CopyPlugin([{ from: 'public', to: './' }]),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'index.html'),
}),
],
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
},
},
stats: {
// Examine all modules
maxModules: Infinity,
// Display bailout reasons
optimizationBailout: true,
},
};