kana/webpack.config.js

73 lines
2 KiB
JavaScript
Raw Normal View History

2016-07-28 17:56:13 +00:00
const NODE_ENV = 'development';
const dotenv = require('dotenv');
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const dotEnvVars = dotenv.config();
const envVariables =
Object.assign({}, dotEnvVars);
const defines =
Object.keys(envVariables)
.reduce((memo, key) => {
const val = JSON.stringify(envVariables[key]);
memo[`__${key.toUpperCase()}__`] = val;
return memo;
}, {
__NODE_ENV__: JSON.stringify(NODE_ENV)
});
2016-07-27 17:13:08 +00:00
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors
'./src/index'
],
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
plugins: [
new HtmlWebPackPlugin({
template: 'src/index.html',
filename: '../index.html'
}),
new webpack.HotModuleReplacementPlugin(),
2016-07-28 17:56:13 +00:00
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin(defines)
2016-07-27 17:13:08 +00:00
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel']
}, {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader']
}, {
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
},
{
2016-07-28 17:56:13 +00:00
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
2016-07-27 17:13:08 +00:00
loader: 'url-loader?limit=25000'
},
{
2016-07-28 17:56:13 +00:00
test: /\.(eot|ttf)$/,
2016-07-27 17:13:08 +00:00
loader: 'file-loader'
}
]
},
postcss: function() {
return [autoprefixer, precss];
}
};