An error occurred while loading the file. Please try again.
-
Christopher Chedeau authored6987b809
var path = require('path');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var relative = process.argv[2] === 'local' ? '.' : '../..';
module.exports = {
devtool: 'source-map',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, relative, 'build'),
filename: '[name].[hash].js',
// TODO: this wouldn't work for e.g. GH Pages.
// Good news: we can infer it from package.json :-)
publicPath: '/'
},
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'eslint-loader',
include: path.resolve(__dirname, relative, 'src')
}
],
loaders: [
{
test: /\.js$/,
include: path.resolve(__dirname, relative, 'src'),
loader: 'babel'
},
{
test: /\.css$/,
include: path.resolve(__dirname, relative, 'src'),
loader: 'style!css!postcss'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
loader: 'file',
},
{
test: /\.(mp4|webm)$/,
loader: 'url?limit=10000'
}
]
},
postcss: function () {
return [ autoprefixer ];
},
plugins: [
// TODO: infer from package.json?
new HtmlWebpackPlugin({ title: 'My React Project' }),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } })
]
};