프로젝트에서 이것을 사용하지는 않았지만 yeoman에서 이것을 발견했습니다. webpack.make.js
.장기간 캐싱은 어떻게 작동하나요?
이 코드 :
config.plugins.push(new CommonsChunkPlugin({
name: 'vendor',
// filename: "vendor.js"
// (Give the chunk a different name)
minChunks: Infinity
// (with more entries, this ensures that no other module
// goes into the vendor chunk)
}));
config.output = {
// Absolute output directory
path: BUILD ? path.join(__dirname, '/dist/client/') : path.join(__dirname, '/.tmp/'),
// Output path from the view of the page
// Uses webpack-dev-server in development
publicPath: BUILD || DEV || E2E ? '/' : `http://localhost:${8080}/`,
//publicPath: BUILD ? '/' : 'http://localhost:' + env.port + '/',
// Filename for entry points
// Only adds hash in build mode
filename: BUILD ? '[name].[hash].js' : '[name].bundle.js',
// Filename for non-entry points
// Only adds hash in build mode
chunkFilename: BUILD ? '[name].[hash].js' : '[name].bundle.js'
};
왜 우리가 [hash]
및 CommonsChunkPlugin
사용 놈이야? 무엇을 의미합니까?
이러한 도구로 간단한 예를 얻을 수 있습니까?
좋은 설명에 감사드립니다. 새 버전을 배포 할 때 정적 파일이 업데이트를 위해 무언가 해시를 가져야한다는 것을 이해합니다. Webpack은 클라이언트를위한 아주 좋은 도구입니다. – modelfak
도움이 된 다행 –