mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-28 09:25:42 +08:00
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
var path = require('path');
|
|
var autoprefixer = require('autoprefixer');
|
|
var webpack = require('webpack');
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
module.exports = {
|
|
devtool: 'source-map',
|
|
entry: './src/index.js',
|
|
output: {
|
|
path: path.join(__dirname, '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, 'src')
|
|
}
|
|
],
|
|
loaders: [
|
|
{
|
|
test: /\.css$/,
|
|
include: path.resolve(__dirname, 'src'),
|
|
loader: 'style!css!postcss'
|
|
},
|
|
{
|
|
test: /\.js$/,
|
|
include: path.resolve(__dirname, 'src'),
|
|
loader: 'babel'
|
|
}
|
|
]
|
|
},
|
|
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 } })
|
|
]
|
|
};
|