1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/webpack.config.js

92 lines
2.6 KiB
JavaScript
Raw Normal View History

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'),
},
}),
new webpack.optimize.ModuleConcatenationPlugin(),
2017-01-06 11:52:44 +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 = {
entry,
2016-11-10 14:26:24 +01:00
resolve: {
extensions: ['.scss', '.css', '.js', '.jsx', '.json'],
2016-11-10 14:26:24 +01:00
},
output: {
path: path.join(__dirname, 'dist/public'),
2016-11-10 14:26:24 +01:00
filename: 'bundle.js',
publicPath: '/static/',
},
module: {
rules: [
2016-11-10 14:26:24 +01:00
{
2017-01-06 11:52:44 +01:00
test: /\.jsx?$/,
2016-11-10 14:26:24 +01:00
exclude: /node_modules/,
loader: 'babel-loader',
2016-11-10 14:26:24 +01:00
include: path.join(__dirname, 'src'),
},
{
test: /(\.scss)$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: true,
importLoaders: 1,
2017-08-28 21:40:44 +02:00
localIdentName: '[name]__[local]___[hash:base64:5]',
},
},
{
loader: 'sass-loader',
options: {
// data: '@import "theme/_config.scss";',
2017-08-28 21:40:44 +02:00
includePaths: [path.resolve(__dirname, './src')],
},
},
],
}),
2016-11-10 14:26:24 +01:00
},
{
test: /\.css$/,
2017-08-28 21:40:44 +02:00
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }),
},
2016-11-10 14:26:24 +01:00
],
},
plugins,
2016-11-10 14:26:24 +01:00
devtool: 'source-map',
devServer: {
proxy: {
'/api': {
target: process.env.UNLEASH_API || 'http://localhost:4242',
changeOrigin: true,
2016-11-10 14:26:24 +01:00
secure: false,
},
},
port: process.env.PORT || 3000,
2016-11-10 14:26:24 +01:00
},
};