-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.dev.config.js
104 lines (93 loc) · 2.22 KB
/
webpack.dev.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const path = require('path');
const Dotenv = require('dotenv-webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const appPath = path.join(__dirname, 'app');
const distPath = path.join(__dirname, 'public');
const exclude = /node_modules/;
const extractSass = new ExtractTextPlugin('css/bundle.css');
module.exports = {
context: appPath,
entry: {
app: 'main.jsx',
},
resolve: {
modules: [
'node_modules',
appPath,
],
symlinks: false,
extensions: ['.js', '.jsx'],
alias: {
'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js'),
},
},
output: {
path: distPath,
filename: 'bundle.[hash].js',
publicPath: '/',
},
devtool: 'source-map',
plugins: [
extractSass,
new Dotenv(),
new HtmlWebpackPlugin({
inject: 'body',
template: 'index.html',
}),
],
module: {
noParse: /(mapbox-gl)\.js$/,
loaders: [
{
test: /\.jsx?$/,
enforce: 'pre',
exclude,
use: [
{
loader: 'eslint-loader',
options: { emitWarning: true },
},
],
},
{
test: /\.jsx?$/,
exclude,
use: [
{ loader: 'react-hot-loader' },
{
loader: 'babel-loader',
query: {
presets: ['babel-preset-react', 'babel-preset-es2015', 'babel-preset-stage-0'].map(require.resolve),
plugins: ['babel-plugin-transform-object-assign', 'babel-plugin-es6-promise'].map(require.resolve),
},
},
],
},
{
test: /\.js$/,
exclude,
use: ['babel-loader'],
},
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{ loader: 'css-loader' },
{ loader: 'sass-loader' },
],
// use style-loader in development
fallback: 'style-loader',
}),
},
{
test: /\.css$/,
use: extractSass.extract({
use: [{ loader: 'css-loader' }],
// use style-loader in development
fallback: 'style-loader',
}),
},
],
},
};