/
webpack.config.js
67 lines (66 loc) · 1.84 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
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
module.exports = {
devtool: 'eval-source-map',
cache: true,
debug: true,
// Starting point for the application server
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./src/index.jsx'
],
// Define resource loaders
module: {
loaders: [
{
test: /\.jsx?$/, // Apply this loader to all JSX files
exclude: /node_modules/, // Don't bother with node modules, though
loader: 'react-hot!babel', // Hot loading react content and transpile with babel. Not appropriate for prod
cacheable: true
},
{
test: /\.css$/,
// What is this black magic?
loader: 'style!css?modules&localIdentName=[name]---[local]---[hash:base64:5]',
},
{
test: /\.scss$/,
//loader: 'style!css!sass' // NOTE: this works for bundling, but not for css-module use
loaders: [
'style',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'resolve-url',
'sass'
],
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
loader: 'file?name=app/generated/[name].[ext]'
},
]
},
// Bundle these files only
resolve: {
extensions: ['', '.js', '.jsx', '.json']
},
output: {
path: __dirname + '/dist/assets', // What folder for the output?
publicPath: '/', // Which public path to expose?
filename: 'bundle.js' // What do we call the output?
},
// externals: nodeModules,
devServer: {
contentBase: './dist',
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"development"'
}
})
]
}