mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 20:07:06 +08:00
feat: utils.buildins()
This commit is contained in:
parent
408ae03a8c
commit
7d9e364b15
@ -71,7 +71,6 @@
|
|||||||
"ora": "^5.4.0",
|
"ora": "^5.4.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup-plugin-esbuild": "^3.0.2",
|
"rollup-plugin-esbuild": "^3.0.2",
|
||||||
"rollup-plugin-node-externals": "^2.2.0",
|
|
||||||
"ts-node": "^9.1.1",
|
"ts-node": "^9.1.1",
|
||||||
"typescript": "^4.2.3",
|
"typescript": "^4.2.3",
|
||||||
"vite": "^2.1.3"
|
"vite": "^2.1.3"
|
||||||
|
@ -5,7 +5,7 @@ import commonjs from '@rollup/plugin-commonjs'
|
|||||||
import esbuild from 'rollup-plugin-esbuild'
|
import esbuild from 'rollup-plugin-esbuild'
|
||||||
import alias from '@rollup/plugin-alias'
|
import alias from '@rollup/plugin-alias'
|
||||||
import json from '@rollup/plugin-json'
|
import json from '@rollup/plugin-json'
|
||||||
import externals from 'rollup-plugin-node-externals'
|
import { builtins } from './utils'
|
||||||
|
|
||||||
export default (env = 'production') => {
|
export default (env = 'production') => {
|
||||||
const options: RollupOptions = {
|
const options: RollupOptions = {
|
||||||
@ -49,9 +49,11 @@ export default (env = 'production') => {
|
|||||||
{ find: '@main', replacement: join(__dirname, '../src/main'), },
|
{ find: '@main', replacement: join(__dirname, '../src/main'), },
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
externals(),
|
|
||||||
],
|
],
|
||||||
external: ['electron'],
|
external: [
|
||||||
|
...builtins(),
|
||||||
|
'electron',
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { builtinModules } from 'module'
|
||||||
import { sep } from 'path'
|
import { sep } from 'path'
|
||||||
import { get } from 'http'
|
import { get } from 'http'
|
||||||
import { green } from 'chalk'
|
import { green } from 'chalk'
|
||||||
@ -39,3 +40,6 @@ export function cjs2esm() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** node.js 内置模块 */
|
||||||
|
export const builtins = () => builtinModules.filter(x => !/^_|^(internal|v8|node-inspect)\/|\//.test(x))
|
||||||
|
@ -2,9 +2,8 @@ require('dotenv').config({ path: join(__dirname, '.env') })
|
|||||||
|
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import externals from 'rollup-plugin-node-externals'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { cjs2esm } from './script/utils'
|
import { builtins } from './script/utils'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@ -20,17 +19,19 @@ export default defineConfig({
|
|||||||
'@root': __dirname,
|
'@root': __dirname,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
optimizeDeps: {
|
|
||||||
exclude: ['electron-store', 'electron']
|
|
||||||
},
|
|
||||||
build: {
|
build: {
|
||||||
outDir: join(__dirname, 'dist/render'),
|
outDir: join(__dirname, 'dist/render'),
|
||||||
|
emptyOutDir: true,
|
||||||
|
minify: false,
|
||||||
|
commonjsOptions: {},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: ['electron'],
|
external: [
|
||||||
plugins: [
|
...builtins(),
|
||||||
externals(),
|
'electron',
|
||||||
// cjs2esm(),
|
|
||||||
],
|
],
|
||||||
|
output: {
|
||||||
|
format: 'cjs',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
36
yarn.lock
36
yarn.lock
@ -1254,14 +1254,6 @@ find-up@^3.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
locate-path "^3.0.0"
|
locate-path "^3.0.0"
|
||||||
|
|
||||||
find-up@^4.1.0:
|
|
||||||
version "4.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
|
|
||||||
integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==
|
|
||||||
dependencies:
|
|
||||||
locate-path "^5.0.0"
|
|
||||||
path-exists "^4.0.0"
|
|
||||||
|
|
||||||
fs-extra@^8.1.0:
|
fs-extra@^8.1.0:
|
||||||
version "8.1.0"
|
version "8.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||||
@ -1771,13 +1763,6 @@ locate-path@^3.0.0:
|
|||||||
p-locate "^3.0.0"
|
p-locate "^3.0.0"
|
||||||
path-exists "^3.0.0"
|
path-exists "^3.0.0"
|
||||||
|
|
||||||
locate-path@^5.0.0:
|
|
||||||
version "5.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
|
|
||||||
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
|
|
||||||
dependencies:
|
|
||||||
p-locate "^4.1.0"
|
|
||||||
|
|
||||||
lodash.camelcase@^4.3.0:
|
lodash.camelcase@^4.3.0:
|
||||||
version "4.3.0"
|
version "4.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
|
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
|
||||||
@ -1989,7 +1974,7 @@ p-cancelable@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc"
|
resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc"
|
||||||
integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==
|
integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==
|
||||||
|
|
||||||
p-limit@^2.0.0, p-limit@^2.2.0:
|
p-limit@^2.0.0:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
|
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
|
||||||
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
|
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
|
||||||
@ -2003,13 +1988,6 @@ p-locate@^3.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-limit "^2.0.0"
|
p-limit "^2.0.0"
|
||||||
|
|
||||||
p-locate@^4.1.0:
|
|
||||||
version "4.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
|
|
||||||
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
|
|
||||||
dependencies:
|
|
||||||
p-limit "^2.2.0"
|
|
||||||
|
|
||||||
p-try@^2.0.0:
|
p-try@^2.0.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
||||||
@ -2040,11 +2018,6 @@ path-exists@^3.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
|
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
|
||||||
integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=
|
integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=
|
||||||
|
|
||||||
path-exists@^4.0.0:
|
|
||||||
version "4.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
|
|
||||||
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
|
|
||||||
|
|
||||||
path-is-absolute@^1.0.0:
|
path-is-absolute@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||||
@ -2350,13 +2323,6 @@ rollup-plugin-esbuild@^3.0.2:
|
|||||||
joycon "^3.0.0"
|
joycon "^3.0.0"
|
||||||
jsonc-parser "^3.0.0"
|
jsonc-parser "^3.0.0"
|
||||||
|
|
||||||
rollup-plugin-node-externals@^2.2.0:
|
|
||||||
version "2.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/rollup-plugin-node-externals/-/rollup-plugin-node-externals-2.2.0.tgz#23946e8c0fdd0e321cc3f225d4cebc3d819d17c4"
|
|
||||||
integrity sha512-WM7TtQ76GdsLceEGmZzQzn1afj8JgOQT5VLs1Y9RMqowM/8eK2mBj/Lv7hoE833U75QsUZIRirYUtFatu51RJA==
|
|
||||||
dependencies:
|
|
||||||
find-up "^4.1.0"
|
|
||||||
|
|
||||||
rollup@^2.38.5:
|
rollup@^2.38.5:
|
||||||
version "2.39.0"
|
version "2.39.0"
|
||||||
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.39.0.tgz#be4f98c9e421793a8fec82c854fb567c35e22ab6"
|
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.39.0.tgz#be4f98c9e421793a8fec82c854fb567c35e22ab6"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user