const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const WebpackNotifierPlugin = require('webpack-notifier');
const config = {
entry: [
'react-hot-loader/patch',
'./_f/app.js'
],
output: {
path: __dirname + "/_p",
filename: "st.js"
},
devServer: {
contentBase: "./_p",
historyApiFallback: true,
inline: true,
port: 2000
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: [
{
loader: 'react-hot-loader/webpack'
},
{
loader: 'babel-loader',
options: {
presets: [
'es2015',
'react',
]
},
}
]
},
{
test: /\.styl/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
minimize: true
}
}, 'autoprefixer-loader?browsers=last 2 versions', 'stylus-loader']
})
}
]
},
plugins: [
new ExtractTextPlugin('st.css'),
new WebpackNotifierPlugin,
new webpack.HotModuleReplacementPlugin()
],
devtool: "cheap-inline-module-source-map",
}
if (process.env.NODE_ENV === 'production') {
config.devtool = false;
config.plugins = [
new ExtractTextPlugin('st.css'),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({comments: false}),
new webpack.DefinePlugin({
'process.env': {NODE_ENV: JSON.stringify('production')}
})
];
};
module.exports = config;