-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
105 lines (102 loc) · 2.53 KB
/
webpack.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
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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const isDebug = process.env.NODE_ENV !== 'production';
console.log('NODE_ENV...', process.env.NODE_ENV);
console.log('Debug mode: ' + isDebug);
module.exports = {
name: 'clearminute app',
target: 'web',
entry: {
browser: ['babel-polyfill', './src/client.jsx'],
},
output: {
path: path.resolve(__dirname + '/build'),
publicPath: isDebug ? '/' : '/',
filename: 'react.bundle.[hash].js',
chunkFilename: '[id].[hash].bundle.js',
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
clearminute: `${__dirname}/src`,
},
},
mode: isDebug ? 'development' : 'production',
module: {
rules: [{
test: /\.jsx?$/,
loader: 'babel-loader',
include: [path.resolve(__dirname, 'src')],
// TODO: Move those options in .babelrc
options: {
cacheDirectory: isDebug,
babelrc: false,
presets: [
[
'env',
{
targets: {
browsers: ['last 2 versions'],
},
modules: false,
},
],
'react',
...(isDebug ? [] : ['react-optimize']),
],
plugins: [
['transform-object-rest-spread']
],
},
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'eslint-loader'
},
{
test: /\.scss$/,
include: [path.normalize(`${__dirname}/src/styles/clearminute.scss`)],
use: [{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
},
],
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
loader: 'file-loader',
},
],
},
bail: !isDebug,
cache: isDebug,
stats: {
colors: true,
reasons: isDebug,
timings: true,
},
plugins: [
new webpack.DefinePlugin({
'process.env.ENV_TYPE': JSON.stringify(process.env.ENV_TYPE),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) || 'development',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
inject: 'body',
chunks: ['browser'],
}),
],
devtool: isDebug ? 'cheap-module-source-map' : false,
};