forked from hypeserver/react-date-range
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
44 lines (42 loc) · 1.16 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const IS_DEV = (process.env.NODE_ENV || 'development') === 'development';
function hotInject(path) {
return IS_DEV ? ['react-hot-loader/patch', path.replace(/\.js$/, '.dev.js')] : [path];
}
module.exports = {
entry: {
main: hotInject(path.resolve('./demo/src/main.js')),
},
output: {
path: path.resolve('./demo/dist'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader?filenameRelative=' + path.resolve('./'),
exclude: /(node_modules)|(demo)/,
},
{
test: /\.js$/,
loader: `babel-loader?extends=${path.resolve('./demo/.babelrc')}&sourceRoot=${path.resolve(
'./'
)}`,
include: path.resolve('./demo'),
},
{
test: /\.s?css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
],
},
plugins: [new HtmlWebpackPlugin({ template: path.resolve('demo/src/index.html') })],
devtool: IS_DEV ? '#eval-source-map' : 'source-map',
devServer: {
hot: true,
publicPath: '/',
},
context: __dirname,
};