Replies: 3 comments 3 replies
-
|
This is what Gemini Pro says: No, it is not considered "safe" for critical production builds. Your suspicion is well-founded. Relying on the Here is the breakdown of why this is unsafe and the better alternatives you should use. 🚨 The Risk: Why
|
Beta Was this translation helpful? Give feedback.
-
|
Option 2 is not so simple. If you are running parallel builds (separate processes), avoiding conflicts in both the Cache and the Output directories is critical to prevent corruption and build errors. Here is the breakdown of exactly what you need to isolate and how. 1. The Cache Directory (CRITICAL)You must isolate the cache. How to do it: // webpack.legacy.js
module.exports = {
// ...
name: 'legacy', // This helps, but cache.name is the specific key
cache: {
type: 'filesystem',
name: 'legacy-build-cache', // Creates: node_modules/.cache/webpack/legacy-build-cache
},
};
// webpack.modern.js
module.exports = {
// ...
name: 'modern',
cache: {
type: 'filesystem',
name: 'modern-build-cache', // Creates: node_modules/.cache/webpack/modern-build-cache
},
};2. The Build/Output Directory (HIGHLY RECOMMENDED)You should use separate directories (or distinct naming patterns). A. The "Clean" Race ConditionMost production builds use
B. Filename CollisionsIf both builds try to output a shared asset (like a font or an image) to the same path (e.g., The Safest Architecture:
Summary Configuration PatternHere is how your config structure should look to be 100% safe for parallel execution: // webpack.base.js (Shared logic)
const path = require('path');
module.exports = (mode) => ({
// Ensure unique cache name based on the mode (legacy/modern)
cache: {
type: 'filesystem',
name: `${mode}-cache`,
},
output: {
// Ensure unique output folder
path: path.resolve(__dirname, `dist/${mode}`),
filename: '[name].[contenthash].js',
clean: true, // Safe to use because we are in a unique folder!
},
plugins: [
new WebpackAssetsManifest({
output: 'manifest.json', // Will exist inside dist/legacy/ and dist/modern/
writeToDisk: true,
})
]
});Would you like a Node.js script that handles the final step: moving the files from the subfolders to the root |
Beta Was this translation helpful? Give feedback.
-
|
@Judahmeek Are you experiencing any issues due to this lib, or is this just a precaution due to the age? As far as I can tell, I have been meaning to switch to a lib that has more recent activity and is not archived.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Last version for lockfile, which
webpack-assets-manifestuses, was released 8 years ago.Beta Was this translation helpful? Give feedback.
All reactions