1
프로덕션 환경에서 bundle.js 파일이 두 번 전송됩니다. 두 번째 시간은 bundle.js 파일 자체에 의해 요청됩니다. 기본적으로 또는 구성 관련 있습니까?동형 앱에서 Webpack bundle.js가 두 번 전송 된 이유는 무엇입니까?
또한 bundle.js가 두 번째 요청되는 시간은 192ms로 처음 634ms보다 훨씬 짧습니다. 어쩌면 파일이 캐시 되었기 때문일 수도 있습니다.
참고 :이 isomorphic 앱이며 은이 모든 애셋 파일을 제공하도록 수정했습니다. 스크린 샷 우는
웹팩 제작 설정 중 일부는 사용하는 메신저 :
module.exports = {
devtool: false,
output: {
path: resolve(__dirname, 'dist', 'www'),
publicPath: '/www/',
filename: 'bundle.js',
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: true,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
output: {
comments: false,
},
}),
new ExtractTextPlugin('styles.css'),
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel-loader',
include: resolve(__dirname, 'src', 'main'),
exclude: /node_modules/,
}, {
test: /\.*css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader', use: 'css-loader?-autoprefixer!sass-loader',
}),
}],
}
};
네트워크 탭에서 bundle.js의 xhr 요청에 대한 초 기자가 bundle.js라는 것을 볼 수 있습니다. 번들에서 해당 파일을 호출해야합니다. 어쩌면 minification을 제거하고 bundle.js가 번들에 언급되어있는 곳에서 읽으십시오. – Axnyff
@Axnyff * retrieveSourceMapURL() * 내부에서 발생하지만 prodution에서 sourceMaps를 가져 오지 않으므로 devtool은 false입니다. : / – Roberto14