我的生产服务器上存在以下问题。生成捆绑包并从有关时间加载捆绑包。每次刷新页面我得到不同的结果,有三种可能的结果:
这是我的webpack的production.config.js:
var config = require('./webpack.config.js');
var BundleTracker = require('webpack-bundle-tracker');
var webpack = require('webpack');
config.output.publicPath = '/static/bundles/';
config.plugins = [
new BundleTracker({filename: './webpack-stats-prod.json'}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
];
config.entry = {
main: './static/js/main',
auth: './static/js/auth',
pathway: './static/js/pathway',
report: './static/js/report',
upload: './static/js/upload'
};
module.exports = config;
我的config.js:
var path = require('path')
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')
module.exports = {
context: __dirname,
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./static/js/main',
'./static/js/auth',
'./static/js/pathway',
'./static/js/report',
'./static/js/upload'
],
entry: {
main: './static/js/main',
auth: './static/js/auth',
pathway: './static/js/pathway',
report: './static/js/report',
upload: './static/js/upload'
},
output: {
path: path.resolve('./static/bundles/'),
filename: '[name]-[hash].js',
publicPath: 'http://localhost:3000/static/bundles/'
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
],
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: ['react']
}
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.png$/,
loader: "url-loader?limit=100000"
},
{
test: /\.(jpg|gif)$/,
loader: "file-loader"
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.css']
}
}
有没有办法解决这种竞争状况?