mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
ignore node_modules
This commit is contained in:
parent
e49e7eefe4
commit
457989c840
@ -43,12 +43,16 @@ const config: UserConfig = {
|
||||
],
|
||||
plugins: [
|
||||
{
|
||||
name: '@rollup/plugin-replace-electron-store',
|
||||
transform(code, id) {
|
||||
// const Store = require('electron-store') -> import Store from 'electron-store'
|
||||
name: '@rollup/plugin-cjs2esm',
|
||||
transform(code, filename) {
|
||||
if (filename.includes('/node_modules/')) {
|
||||
return code
|
||||
}
|
||||
|
||||
const electronStoreReg = /(const|let|var)[\n\s]+(\w+)[\n\s]*=[\n\s]*require\(["|'](.+)["|']\)/g
|
||||
const res = code.match(electronStoreReg)
|
||||
if (res) {
|
||||
// const Store = require('electron-store') -> import Store from 'electron-store'
|
||||
code = code.replace(electronStoreReg, `import $2 from '$3'`)
|
||||
}
|
||||
return code
|
||||
|
Loading…
x
Reference in New Issue
Block a user