代码拉取完成,页面将自动刷新
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;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。