2016-11-10 14:26:24 +01:00
|
|
|
// docs: http://webpack.github.io/docs/configuration.html
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
|
2016-11-16 22:19:38 +01:00
|
|
|
const entry = ['whatwg-fetch', './src/index'];
|
2017-01-06 11:52:44 +01:00
|
|
|
const plugins = [
|
|
|
|
new ExtractTextPlugin('bundle.css', { allChunks: true }),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
];
|
2016-11-10 22:49:28 +01:00
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
entry.push('webpack-dev-server/client?http://localhost:3000');
|
|
|
|
entry.push('webpack/hot/only-dev-server');
|
|
|
|
plugins.push(new webpack.HotModuleReplacementPlugin());
|
|
|
|
}
|
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
module.exports = {
|
2016-11-10 22:49:28 +01:00
|
|
|
entry,
|
2016-11-10 14:26:24 +01:00
|
|
|
|
|
|
|
resolve: {
|
|
|
|
root: [path.join(__dirname, 'src')],
|
|
|
|
extensions: ['', '.scss', '.css', '.js', '.jsx', '.json'],
|
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
2017-03-07 18:30:45 +01:00
|
|
|
path: path.join(__dirname, 'dist/public'),
|
2016-11-10 14:26:24 +01:00
|
|
|
filename: 'bundle.js',
|
|
|
|
publicPath: '/static/',
|
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
2017-01-06 11:52:44 +01:00
|
|
|
test: /\.jsx?$/,
|
2016-11-10 14:26:24 +01:00
|
|
|
exclude: /node_modules/,
|
2017-01-06 11:52:44 +01:00
|
|
|
loader: 'babel',
|
2016-11-10 14:26:24 +01:00
|
|
|
include: path.join(__dirname, 'src'),
|
|
|
|
},
|
|
|
|
{
|
2016-12-20 19:15:12 +01:00
|
|
|
test: /(\.scss)$/,
|
2016-11-10 14:26:24 +01:00
|
|
|
loader: ExtractTextPlugin.extract('style',
|
2017-01-06 11:52:44 +01:00
|
|
|
'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass'),
|
2016-11-10 14:26:24 +01:00
|
|
|
},
|
2016-12-20 19:15:12 +01:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2016-12-22 10:42:41 +01:00
|
|
|
loader: ExtractTextPlugin.extract('style', 'css'),
|
2016-12-20 19:15:12 +01:00
|
|
|
},
|
2016-11-10 14:26:24 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2016-11-10 22:49:28 +01:00
|
|
|
plugins,
|
2016-11-10 14:26:24 +01:00
|
|
|
|
|
|
|
sassLoader: {
|
2016-12-04 11:56:41 +01:00
|
|
|
// data: '@import "theme/_config.scss";',
|
2016-11-10 14:26:24 +01:00
|
|
|
includePaths: [path.resolve(__dirname, './src')],
|
|
|
|
},
|
|
|
|
|
|
|
|
devtool: 'source-map',
|
|
|
|
|
|
|
|
externals: {
|
|
|
|
// stuff not in node_modules can be resolved here.
|
|
|
|
},
|
|
|
|
|
|
|
|
devServer: {
|
|
|
|
proxy: {
|
2016-11-10 22:49:28 +01:00
|
|
|
'/api': {
|
2017-01-02 22:07:50 +01:00
|
|
|
target: process.env.UNLEASH_API || 'http://localhost:4242',
|
|
|
|
changeOrigin: true,
|
2016-11-10 14:26:24 +01:00
|
|
|
secure: false,
|
|
|
|
},
|
|
|
|
},
|
2017-01-02 22:23:13 +01:00
|
|
|
port: process.env.PORT || 3000,
|
2016-11-10 14:26:24 +01:00
|
|
|
},
|
|
|
|
};
|