External js files (import by main entry file) built without obfuscation or minify
See original GitHub issueMy project has the following directory structure:
src
ㄴ main
ㄴ utils
test.js
index.js
ㄴ renderer
main.js
...
If i build the package using vite-plugin-electron
, the build succeeds, but when i import and use an external js file like the src/main/utils/test.js
file, the file is built without minify or code obfuscation. The main/utils/test.js
file in the build output path is the same as the existing file.
Is there a way to obfuscate (or minify) external js files other than the main entry file? Or is this a bug?
here is my vite.config.js
:
import { defineConfig } from 'vite'
import electron from 'vite-plugin-electron'
import vue from '@vitejs/plugin-vue'
import { resolve, join } from 'path'
import { builtinModules } from 'module'
export default defineConfig({
base: './',
root: resolve('./src/renderer'),
publicDir: resolve('./src/renderer/public'),
build: {
outDir: resolve('./dist')
},
plugins: [
vue(),
electron({
main: {
entry: 'src/main/index.js',
vite: {
publicDir: resolve('./src/main'),
build: {
emptyOutDir: true,
assetsDir: '.',
outDir: 'dist/main',
rollupOptions: {
external: [
'electron',
...builtinModules
]
}
}
}
},
renderer: {}
})
]
})
Thank you.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
HTML: using external .js file with import statements
js which I have imported in the head of my HTML file. Everything seems to work great, until my ~/src/Main.
Read more >API - esbuild
This setting is a convention from Webpack that esbuild respects for any imported file, not just files used with inject. #Loader. Supported by:...
Read more >How to Optimize JavaScript Delivery to Speed Up Your Site
Use minified JS files True minification also uses obfuscation, which renames variables to names that require fewer bytes of data for the browser...
Read more >How to use an external JS file and CSS file on a Mac - Quora
Minified javaScript files are used to speed up loading of web page. Minification process remove unnecessary spaces and returns (redundant code in some...
Read more >How to use external JS files and JavaScript code in Angular 6/7
In this tutorial you can learn how to use external js files and how to use JavaScript code in Angular 6/7.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi here! 👋 The feature implemented in
v0.10.0
#89Minify multiple files planned next version(coming soon). But waiting for Vite’s
lib.entry
to support multi-entry, I have noticed that the latest code already supports multi-entry, ant it should be supported in Vite@3.2.0 version. I’m also waiting for it to be released. 😄