-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
93 lines (85 loc) · 2.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
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
const webpack = require('webpack');
const path = require('path');
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,
],
extensions: ['.js', '.jsx'],
alias: {
'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js'),
},
},
output: {
path: distPath,
filename: 'bundle.[hash].js',
publicPath: '/',
},
module: {
noParse: /(mapbox-gl)\.js$/,
loaders: [
{
test: /\.jsx?$/,
exclude,
use: [
{
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,
loaders: ['babel-loader'],
},
{
test: /\.scss$/,
loader: extractSass.extract({
use: [
{ loader: 'css-loader' },
{ loader: 'sass-loader' },
],
// use style-loader in development
fallback: 'style-loader',
}),
},
{
test: /\.css$/,
loader: extractSass.extract({
use: [{ loader: 'css-loader' }],
// use style-loader in development
fallback: 'style-loader',
}),
},
],
},
plugins: [
extractSass,
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
DEV_TABLES: JSON.stringify(process.env.DEV_TABLES),
CARTO_DOMAIN: JSON.stringify(process.env.CARTO_DOMAIN),
},
}),
new HtmlWebpackPlugin({
inject: 'body',
template: 'index.html',
}),
],
};