-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathwebpack.common.js
58 lines (56 loc) · 1.46 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
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const AssetsPlugin = require('assets-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const { SRC, DIST } = require('./src/config/paths');
module.exports = {
devtool: 'source-map',
cache: true,
context: SRC,
output: {
path: DIST,
filename: '[name].js',
publicPath: '/dist/'
},
plugins: [
new ProgressBarPlugin(),
new ExtractTextPlugin('[name].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|svg)$/i,
use: [
'file-loader?name=[name].[ext]'
]
}
]
}
};