/
webpack.config.js
57 lines (54 loc) · 1.43 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
const path = require('path'); // path module help us to access path routes
const SRC_DIR = path.resolve(__dirname, 'app/src'); // Source directory
const DIST_DIR = path.resolve(__dirname, 'app/dist'); // Distribution directory
const webpack = require('webpack');
const ENV = process.env.NODE_ENV;
module.exports = {
entry: {
client: SRC_DIR + '/index.js' // My entry file
},
// My output file
output: {
path: DIST_DIR,
filename: 'bundle.js',
publicPath: ENV == 'development' ? 'dist/' : './dist/',
chunkFilename: '[name].bundle.js'
},
resolve: {
extensions: [ '.js', '.json', '.jsx', 'css', 'svg']
},
module : {
rules : [
// Loader for JSX files
{
test : /\.jsx?/,
exclude: /node_modules|libs/,
include : SRC_DIR,
loader : 'babel-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jp(e*)g)$/,
use: ['url-loader']
},
{
test: /\.(svg)$/,
loader: 'url-loader?limit=100000&name=./app/dist/imgs/[hash].[ext]'
}
]
},
// Source mapping allow us to debug code from src files
devtool: 'source-map',
// Dev Server configuration
devServer: {
contentBase: './app/',
hot: true // with hot reload
},
plugins : [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
]
};