mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
improve webpack clean configuration with build folder filtering
This commit is contained in:
4
npm-packages/meteor-rspack/package-lock.json
generated
4
npm-packages/meteor-rspack/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@meteorjs/rspack",
|
||||
"version": "0.0.29",
|
||||
"version": "0.0.30",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@meteorjs/rspack",
|
||||
"version": "0.0.29",
|
||||
"version": "0.0.30",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"ignore-loader": "^0.1.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@meteorjs/rspack",
|
||||
"version": "0.0.29",
|
||||
"version": "0.0.30",
|
||||
"description": "Configuration logic for using Rspack in Meteor projects",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
|
||||
@@ -98,6 +98,16 @@ function createCoffeescriptConfig({ swcConfig }) {
|
||||
};
|
||||
}
|
||||
|
||||
// Keep files outside of build folders
|
||||
function keepOutsideBuild() {
|
||||
return (p) => {
|
||||
const normalized = '/' + path.normalize(p).replaceAll(path.sep, '/').replace(/^\/+/, '');
|
||||
const isInBuildRoot = /\/_build(\/|$)/.test(normalized);
|
||||
const isInBuildStar = /\/_build-[^/]+(\/|$)/.test(normalized);
|
||||
return !(isInBuildRoot || isInBuildStar); // true => KEEP, false => DELETE
|
||||
};
|
||||
}
|
||||
|
||||
// Watch options shared across both builds
|
||||
const defaultWatchOptions = {
|
||||
ignored: ['**/.meteor/local/**', '**/dist/**'],
|
||||
@@ -282,7 +292,7 @@ export default function (inMeteor = {}, argv = {}) {
|
||||
cssChunkFilename: `${assetsContext}/[id]${
|
||||
isProd ? '.[contenthash]' : ''
|
||||
}.css`,
|
||||
clean: isProd,
|
||||
...(isProd && { clean: { keep: keepOutsideBuild() } }),
|
||||
},
|
||||
optimization: {
|
||||
usedExports: true,
|
||||
@@ -371,7 +381,7 @@ export default function (inMeteor = {}, argv = {}) {
|
||||
libraryTarget: 'commonjs',
|
||||
chunkFilename: `${bundlesContext}/[id]${isProd ? '.[chunkhash]' : ''}.js`,
|
||||
assetModuleFilename: `${assetsContext}/[hash][ext][query]`,
|
||||
clean: isProd,
|
||||
...(isProd && { clean: { keep: keepOutsideBuild() } }),
|
||||
},
|
||||
optimization: { usedExports: true },
|
||||
module: {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
export const DEFAULT_RSPACK_VERSION = '1.4.8';
|
||||
|
||||
export const DEFAULT_METEOR_RSPACK_VERSION = '0.0.29';
|
||||
export const DEFAULT_METEOR_RSPACK_VERSION = '0.0.30';
|
||||
|
||||
export const DEFAULT_METEOR_RSPACK_REACT_HMR_VERSION = '1.4.3';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user