我的 webpack 配置文件(React 项目),自己动手搭的,留作参考
const webpack = require('webpack')
const path = require('path')
const ManifistPlugin = require('webpack-manifest-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const modules = require('./config/base')
const config = {
entry: [
'babel-polyfill',
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:9000',
path.join(__dirname, '/src/container/render')
],
output: {
publicPath: 'http://localhost:9000/',
path: path.join(__dirname, '/dist'),
filename: '[name].[hash:5].js'
},
module: modules,
resolve: {
extensions: ['.js', '.jsx', '.json', '.css', '.scss', '.sass'],
alias: {
'@': path.join(__dirname, '/src/container')
}
},
devServer: {
publicPath: path.join(__dirname, '/dist'),
contentBase: path.join(__dirname, '/dist'),
historyApiFallback: true,
port: 9000,
hot: true,
inline: true,
stats: 'normal'
},
plugins: [
new ManifistPlugin(),
new ExtractTextPlugin('/style.css'),
new HtmlWebpackPlugin({
template: path.join(__dirname, '/index.html')
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin({}),
new webpack.SourceMapDevToolPlugin({
filename: '[name].[hash:5].map'
})
]
}
module.exports = config