2015-06-15 15:21:19 +02:00
|
|
|
|
"use strict";
|
|
|
|
|
var webpack = require('webpack');
|
|
|
|
|
var path = require('path');
|
|
|
|
|
var loaders = require('./webpack.loaders');
|
|
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
|
|
|
|
|
|
const HOST = process.env.HOST || "127.0.0.1";
|
|
|
|
|
const PORT = process.env.PORT || "8888";
|
|
|
|
|
|
|
|
|
|
// global css
|
|
|
|
|
loaders.push({
|
2016-12-16 15:04:17 +01:00
|
|
|
|
test: /[\/\\](node_modules|global)[\/\\].*\.css$/,
|
|
|
|
|
loaders: [
|
|
|
|
|
'style?sourceMap',
|
|
|
|
|
'css'
|
|
|
|
|
]
|
2015-06-15 15:21:19 +02:00
|
|
|
|
});
|
|
|
|
|
// local scss modules
|
|
|
|
|
loaders.push({
|
2016-12-16 15:04:17 +01:00
|
|
|
|
test: /[\/\\]src[\/\\].*\.scss/,
|
|
|
|
|
loaders: [
|
|
|
|
|
'style?sourceMap',
|
|
|
|
|
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
|
|
|
|
|
'sass'
|
|
|
|
|
]
|
2015-06-15 15:21:19 +02:00
|
|
|
|
});
|
|
|
|
|
// local css modules
|
|
|
|
|
loaders.push({
|
2016-12-16 15:04:17 +01:00
|
|
|
|
test: /[\/\\]src[\/\\].*\.css/,
|
|
|
|
|
loaders: [
|
|
|
|
|
'style?sourceMap',
|
|
|
|
|
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
|
|
|
|
|
]
|
2015-06-15 15:21:19 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2016-12-16 15:04:17 +01:00
|
|
|
|
target: 'web',
|
|
|
|
|
entry: [
|
|
|
|
|
`webpack-dev-server/client?http://${HOST}:${PORT}`,
|
|
|
|
|
`webpack/hot/only-dev-server`,
|
|
|
|
|
`./src/index.jsx` // Your appʼs entry point
|
|
|
|
|
],
|
|
|
|
|
devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map',
|
|
|
|
|
output: {
|
|
|
|
|
path: path.join(__dirname, 'public'),
|
|
|
|
|
filename: 'bundle.js'
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'webworkify': 'webworkify-webpack',
|
|
|
|
|
// TODO: otherwise I get a max call stack error in browser?
|
|
|
|
|
// 'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js')
|
|
|
|
|
},
|
|
|
|
|
extensions: ['', '.js', '.jsx']
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
loaders,
|
|
|
|
|
postLoaders: [{
|
|
|
|
|
include: /node_modules\/mapbox-gl-shaders/,
|
|
|
|
|
loader: 'transform',
|
|
|
|
|
query: 'brfs'
|
|
|
|
|
}]
|
|
|
|
|
},
|
|
|
|
|
node: {
|
|
|
|
|
fs: "empty",
|
2016-12-03 23:28:43 +01:00
|
|
|
|
net: 'empty',
|
|
|
|
|
tls: 'empty'
|
2016-12-16 15:04:17 +01:00
|
|
|
|
},
|
|
|
|
|
devServer: {
|
|
|
|
|
contentBase: "./public",
|
|
|
|
|
// do not print bundle build stats
|
|
|
|
|
noInfo: true,
|
|
|
|
|
// enable HMR
|
|
|
|
|
hot: true,
|
|
|
|
|
// embed the webpack-dev-server runtime into the bundle
|
|
|
|
|
inline: true,
|
|
|
|
|
// serve index.html in place of 404 responses to allow HTML5 history
|
|
|
|
|
historyApiFallback: true,
|
|
|
|
|
port: PORT,
|
|
|
|
|
host: HOST
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
new webpack.NoErrorsPlugin(),
|
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
|
title: 'Maputnik',
|
|
|
|
|
template: './src/template.html'
|
|
|
|
|
}),
|
|
|
|
|
]
|
2015-06-15 15:21:19 +02:00
|
|
|
|
};
|