Build with minify is adding the character "$" #20711
Unanswered
gppinheiro
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using vite accross multiple repositories, and after a few months I finally started having some problems due to the variable $ of JQuery. How can I avoid 'esbuild' or 'terser' to not minify using $ or jquery? I already tried multiple things, but without success.
For now, I have the following configuration:
`const { defineConfig } = require('vite');
const path = require('path');
module.exports = defineConfig(({ mode }) => {
const isLocal = mode.includes('.local');
// Define widget configurations
const widgetConfigs = {
'list-packages': {
entry: 'wwwroot/components/catalog/catalog-management/list-packages/main.js',
name: 'ListPackagesWidget',
outDir: 'wwwroot/components/catalog/catalog-management/list-packages'
},
'add-package': {
entry: 'wwwroot/components/catalog/catalog-management/add-package/main.js',
name: 'AddPackageWidget',
outDir: 'wwwroot/components/catalog/catalog-management/add-package'
},
'edit-package': {
entry: 'wwwroot/components/catalog/catalog-management/edit-package/main.js',
name: 'EditPackageWidget',
outDir: 'wwwroot/components/catalog/catalog-management/edit-package'
}
};
// Get widget name from mode (remove .local suffix if present)
const widgetName = mode.replace('.local', '');
const config = widgetConfigs[widgetName] || widgetConfigs['list-packages'];
return {
resolve: {
alias: {
'@utils': path.resolve(__dirname, 'wwwroot/components/catalog/shared/utils'),
'@managers': path.resolve(__dirname, 'wwwroot/components/catalog/shared/managers')
}
},
server: {
port: 8080,
open: 'wwwroot/components/catalog'
},
build: {
lib: {
entry: config.entry,
name: config.name,
fileName: 'init',
formats: ['es']
},
outDir: config.outDir,
emptyOutDir: false,
sourcemap: false,
minify: !isLocal,
rollupOptions: {
output: {
entryFileNames: 'init.js'
}
},
},
esbuild: {
target: 'es2024',
legalComments: 'none',
minifyIdentifiers: false,
keepNames: true,
minifySyntax: true,
minifyWhitespace: true
}
};
}); `
This works, but the minify is not really a minify. It's jsut a bundle. How can we solve this?
Beta Was this translation helpful? Give feedback.
All reactions