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: [
|
plugins: [
|
||||||
{
|
{
|
||||||
name: '@rollup/plugin-replace-electron-store',
|
name: '@rollup/plugin-cjs2esm',
|
||||||
transform(code, id) {
|
transform(code, filename) {
|
||||||
// const Store = require('electron-store') -> import Store from 'electron-store'
|
if (filename.includes('/node_modules/')) {
|
||||||
|
return code
|
||||||
|
}
|
||||||
|
|
||||||
const electronStoreReg = /(const|let|var)[\n\s]+(\w+)[\n\s]*=[\n\s]*require\(["|'](.+)["|']\)/g
|
const electronStoreReg = /(const|let|var)[\n\s]+(\w+)[\n\s]*=[\n\s]*require\(["|'](.+)["|']\)/g
|
||||||
const res = code.match(electronStoreReg)
|
const res = code.match(electronStoreReg)
|
||||||
if (res) {
|
if (res) {
|
||||||
|
// const Store = require('electron-store') -> import Store from 'electron-store'
|
||||||
code = code.replace(electronStoreReg, `import $2 from '$3'`)
|
code = code.replace(electronStoreReg, `import $2 from '$3'`)
|
||||||
}
|
}
|
||||||
return code
|
return code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user