-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.dev.js
85 lines (79 loc) · 2.58 KB
/
webpack.config.dev.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
const webpack = require('webpack');
const path = require('path');
const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'development';
const mode = process.env.NODE_ENV === 'production' ? 'prod' : 'dev';
const port = +process.env.PORT || 9000;
module.exports = {
devtool: 'source-map',
target: 'web',
entry: [
'babel-polyfill',
'setimmediate',
'isomorphic-fetch',
path.join(__dirname, 'node_modules', 'highlight.js', 'styles', 'railscasts.css'),
path.join(__dirname, 'node_modules', 'font-awesome', 'scss', 'font-awesome.scss'),
path.join(__dirname, 'src', 'assets', 'scss', 'main.scss'),
path.join(__dirname, 'src', `index.${mode}`),
],
resolve: {
extensions: ['.js', '.jsx', '.json'],
// Avoids : https://facebook.github.io/react/warnings/refs-must-have-owner.html
alias: {
react: path.resolve('node_modules/react'),
},
},
output: {
path: path.join(__dirname, 'public'),
filename: 'codelabs.js',
library: 'CodeLabs',
libraryTarget: 'umd',
publicPath: '/',
umdNamedDefine: true,
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(NODE_ENV),
},
}),
],
module: {
rules: [
// Styles
{ test: /\.css$/, use: [{ loader: 'style-loader' }, { loader: 'css-loader' }] },
{ test: /\.(scss|sass)$/, use: [{ loader: 'style-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }] },
{ test: /\.less$/, use: [{ loader: 'style-loader' }, { loader: 'css-loader' }, { loader: 'less-loader' }] },
// JS
{ test: /\.jsx?$/, use: [{ loader: 'babel-loader' }] },
// md
{ test: /\.md$/, use: [{ loader: 'raw-loader' }] },
// Images
{ test: /\.(jpe?g|png|gif)$/i, use: [{ loader: 'url-loader' }] },
// Font
{ test: /\.svg(\?[a-z0-9=&.]+)?$/, use: [{ loader: 'url-loader' }] },
{ test: /\.woff(\?[a-z0-9=&.]+)?$/, use: [{ loader: 'url-loader' }] },
{ test: /\.woff2(\?[a-z0-9=&.]+)?$/, use: [{ loader: 'url-loader' }] },
{ test: /\.[ot]tf(\?[a-z0-9=&.]+)?$/, use: [{ loader: 'url-loader' }] },
{ test: /\.eot(\?[a-z0-9=&.]+)?$/, use: [{ loader: 'url-loader' }] },
],
},
devServer: {
historyApiFallback: true,
contentBase: [
path.join(__dirname, 'public'),
path.join(__dirname, '_posts', 'codelabs'),
],
hot: true,
inline: true,
port,
stats: {
chunks: false,
},
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300,
poll: 1000,
},
},
};