This repository was archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.common.js
75 lines (73 loc) · 1.91 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
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const AssetsPlugin = require('assets-webpack-plugin');
const Visualizer = require('webpack-visualizer-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const { SRC, DIST } = require('./src/config/paths');
module.exports = {
devtool: 'source-map',
cache: true,
context: SRC,
entry: {
app: [`${SRC}/client-entry.jsx`],
polyfills: [`${SRC}/polyfills.js`],
},
output: {
path: DIST,
filename: '[name]-[chunkhash].js',
publicPath: '/',
},
plugins: [
new ProgressBarPlugin(),
new webpack.HashedModuleIdsPlugin(),
new Visualizer({
filename: '../webpack-stats.html',
}),
new ExtractTextPlugin('[name]-[hash].css'),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.PORT': JSON.stringify(process.env.PORT),
'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new AssetsPlugin({ filename: 'compiled/webpack-assets.json' }),
],
resolve: {
modules: ['node_modules', SRC],
extensions: ['.js', '.jsx', '.scss'],
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [/src/],
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
{
test: /\.s?css$/,
include: [/src/],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader', 'sass-loader'],
}),
},
{
test: /\.(jpe?g|png|gif)$/i,
use: [
'file-loader?name=[name].[ext]',
],
},
{
test: /\.svg$/,
include: [/src/],
loader: 'svg-inline-loader',
options: {
removeSVGTagAttrs: false,
},
},
],
},
};