/
webpack.config.js
58 lines (55 loc) · 1.41 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
'use strict';
// Creates new index.html in build folder that will link to our react app entry point
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports = {
devtool: 'eval-source-map',
// Transform the following code
entry: [
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, './app/index.js')
],
// Resulting file from transformation
output: {
path: path.join(__dirname, '/dist/'),
filename: '[name].js',
publicPath: '/'
},
// How to transform
module: {
loaders: [
// Use Babel to transform all js files in app folder
{
test: /\.js$/,
include: __dirname + '/app',
loader: 'babel-loader'
},
// For SASS
{
test: /\.css$/,
include: path.join(__dirname, '/app'),
loaders: ["style","css","sass"]
},
//images
{
test: /\.(png|jpg)$/,
loader: 'url?limit=25000'
}
]
},
plugins: [
HtmlWebpackPluginConfig,
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
]
}