-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.babel.js
124 lines (121 loc) · 3.09 KB
/
webpack.config.babel.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './client/src/index.html',
filename: 'index.html',
inject: 'body'
});
const debug = process.env.NODE_ENV !== 'production';
module.exports = {
entry: ['whatwg-fetch', './client/src/js/index.jsx'],
output: {
path: path.resolve(__dirname, 'client/dist'),
filename: 'bundle.js',
publicPath: ''
},
externals: {
Materialize: 'Materialize',
jquery: 'jQuery',
materialize: 'materialize'
},
module: {
loaders: [
// > JS
{ test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
// > JSX
{ test: /\.jsx$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{ test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'stage-2']
}
},
// > CSS / SCSS
{ test: /\.(css|scss)?$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
},
{
test: /\.(jpe?g|png|gif|svg|ico)$/i,
use: [
'url-loader?limit=10000',
'img-loader'
]
},
// > MATERIALIZE LOADERS
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{ test: /\.(ttf|eot|svg|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}
] // loaders
}, // modules
// > Module Folders (packages and extensions)
resolve: {
modules: ['node_modules', 'client/src'],
extensions: ['.js', '.jsx', '.json', '.css', '.scss']
}, // modules
plugins: debug ? [
HtmlWebpackPluginConfig,
new webpack.optimize.OccurrenceOrderPlugin(),
new ExtractTextPlugin({
filename: 'bundle.css',
allChunks: true
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Hammer: 'hammerjs/hammer',
createDayLabel: 'jquery',
createWeekdayLabel: 'jquery',
activateOption: 'jquery',
leftPosition: 'jquery'
})
] : [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin(),
HtmlWebpackPluginConfig,
new ExtractTextPlugin({
filename: 'bundle.css',
allChunks: true
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Hammer: 'hammerjs/hammer',
createDayLabel: 'jquery',
createWeekdayLabel: 'jquery',
activateOption: 'jquery',
leftPosition: 'jquery'
})
], // plugins
devServer: {
proxy: {
'/api/v1': process.env.PORT || 'http://localhost:7000'
},
hot: true,
historyApiFallback: true
}, // devServer
node: {
net: 'empty',
dns: 'empty'
}
};