1 Star 0 Fork 0

tsword/react-page-ie8

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.prod.js 4.29 KB
一键复制 编辑 原始数据 按行查看 历史
tsword 提交于 2018-06-28 14:42 . up config
const path = require('path');
const webpack = require('webpack');
const AssetsPlugin = require('assets-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const Es3ifyPlugin = require('es3ify-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const helper = require('./webpack.config.helper');
const config = {
entry: {
index: './src/index.js',
vendor: ['es5-shim', 'es5-shim/es5-sham', 'es6-promise', 'fetch-ie8', 'console-polyfill'],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[chunkhash:8].bundle.js',
chunkFilename: '[name].[chunkhash:8].chunk.js',
publicPath: '/',
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: ['vendor', 'manifest'],
filename: '[name].[chunkhash:8].js'
}),
// 压缩js文件,ie8支持插件使用Es3ifyPlugins
// new webpack.optimize.UglifyJsPlugin({
// mangle: {
// screw_ie8: false, // 支持ie8
// }, // 混淆
// compress: {
// warnings: false, // 去除警告
// screw_ie8: false, // 支持ie8
// }, // 压缩
// comments: false, // 去除注释
// }),
new Es3ifyPlugin(),
// 定义全局环境变量为生产环境
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new AssetsPlugin({
filename: 'dist/webpack-assets.js',
processOutput(assets) {
return `window.WEBPACK_ASSETS = ${JSON.stringify(assets)}`;
},
}),
new ExtractTextPlugin('style.all.[hash:8].css'),
// new HtmlWebpackPlugin({
// filename: 'index.html',
// template: path.resolve(__dirname, 'src/index.ejs'),
// chunks: ['manifest', 'vendor', 'index']
// })
],
resolve: {
// 空字符串在此是为了resolve一些在import文件时不带文件扩展名的表达式
extensions: ['', '.js', 'jsx'],
// 路径别名
alias: {
'~': path.resolve(__dirname, 'src'),
'~home': path.resolve(__dirname, 'src/home'),
'~containers': path.resolve(__dirname, 'src/containers'),
'~components': path.resolve(__dirname, 'src/components'),
'~actions': path.resolve(__dirname, 'src/actions'),
'~api': path.resolve(__dirname, 'src/api'),
'~assets': path.resolve(__dirname, 'src/assets'),
},
},
debug: false,
// devtool: 'source-map',
module: {
loaders: [
{
test: /\.(css|less)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css?modules&localIdentName=[local]-[hash:base64:5]!less-loader'),
},
{
test: /\.(scss|sass)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css?modules&localIdentName=[local]-[hash:base64:5]!sass-loader'),
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: ['babel-loader', /*'eslint-loader'*/],
},
{
test: /(fontawesome-webfont|glyphicons-halflings-regular)\.(woff|woff2|ttf|eot|svg)($|\?)/,
loader: 'url?limit=1024&name=fonts/[name].[hash].[ext]',
},
{
test: /\.(jpg|png)$/,
loader: 'url?limit=100000',
},
{
test: /\.json$/,
loader: 'json',
},
],
postLoaders: [
{
test: /\.js$/,
loaders: ['es3ify-loader'],
},
],
},
devServer: {
// proxy: {
// '/test1': {
// target: 'http://192.168.31.8:9000',
// secure: false,
// },
// },
// contentBase: "./",
// historyApiFallback:true,
// inline:true, //npm start "webpack-dev-server --inline"
// hot:true
},
};
helper.extendEntires(config);
helper.extendHtmlPluginList(config);
module.exports=config;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/tsword/react-page-ie8.git
git@gitee.com:tsword/react-page-ie8.git
tsword
react-page-ie8
react-page-ie8
master

搜索帮助