-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
107 lines (104 loc) · 2.7 KB
/
Copy pathwebpack.config.js
File metadata and controls
107 lines (104 loc) · 2.7 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* global process */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const Path = require('path');
const env = process.env.NODE_ENV || 'dev';
const paths = {
srcJs: Path.resolve('client', 'src', 'js'),
srcSass: Path.resolve('client', 'src', 'sass'),
dist: Path.resolve('client', 'dist'),
};
module.exports = {
entry: {
main: Path.join(paths.srcJs, 'boot', 'index.jsx'),
},
output: {
path: paths.dist,
filename: Path.join('js', '[name].js'),
},
devtool: (env !== 'production') ? 'source-map' : false,
resolve: {
modules: [
paths.srcSass,
paths.srcJs,
'node_modules',
],
extensions: ['.js', '.jsx', '.json'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
options: {
presets: [
['es2015', { modules: false }],
'es2016',
'es2017',
'react',
],
plugins: ['transform-object-rest-spread'],
comments: false,
cacheDirectory: (env !== 'production'),
},
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
plugins: [
autoprefixer(),
],
},
},
{
loader: 'resolve-url-loader',
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [paths.srcSass, paths.srcJs],
},
},
],
// to counter the `css/` in the ExtractTextPlugin() call
publicPath: '../',
}),
},
{
test: /\.(png|gif|jpe?g|svg)$/,
loader: 'file-loader',
options: {
name: Path.join('images', '[name].[ext]'),
},
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env),
},
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor'],
// move any modules inside "node_modules" to inside the vendor dist file
minChunks: module => module.context && module.context.indexOf('/node_modules/') > -1,
}),
new ExtractTextPlugin({ filename: Path.join('css', '[name].css'), allChunks: true }),
],
};