From 26c62404512f4d36ac6c18d3d868d18caa1c2e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Sun, 6 Sep 2020 17:35:02 +0800 Subject: [PATCH] chore: update --- package.json | 2 ++ script/rollup.config.js | 27 ++++++++++++++++++++++++--- yarn.lock | 9 ++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 77b58d4..32f2b0e 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,9 @@ "vue": "^3.0.0-rc.8" }, "devDependencies": { + "@rollup/plugin-alias": "^3.1.1", "@rollup/plugin-commonjs": "^15.0.0", + "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^9.0.0", "@vue/compiler-sfc": "^3.0.0-rc.8", "chalk": "^4.1.0", diff --git a/script/rollup.config.js b/script/rollup.config.js index 8984925..65f8e02 100644 --- a/script/rollup.config.js +++ b/script/rollup.config.js @@ -2,6 +2,8 @@ const path = require('path') const { nodeResolve } = require('@rollup/plugin-node-resolve') const commonjs = require('@rollup/plugin-commonjs') const esbuild = require('rollup-plugin-esbuild') +const alias = require('@rollup/plugin-alias') +const json = require('@rollup/plugin-json') module.exports = (env = 'production') => { return { @@ -13,8 +15,9 @@ module.exports = (env = 'production') => { sourcemap: true, }, plugins: [ - nodeResolve(), + nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告 commonjs(), + json(), esbuild({ // All options are optional include: /\.[jt]sx?$/, // default, inferred from `loaders` option @@ -36,9 +39,27 @@ module.exports = (env = 'production') => { '.json': 'json', // Enable JSX in .js files too '.js': 'jsx' - } + }, }), + alias({ + entries: [ + { find: '@main', replacement: path.join(__dirname, '../src/main'), }, + ] + }) + ], + external: [ + 'crypto', + 'assert', + 'fs', + 'util', + 'os', + 'events', + 'child_process', + 'http', + 'https', + 'path', + 'electron', + 'electron-is-dev', ], - external: ['fs', 'path', 'electron', 'electron-is-dev'], } } diff --git a/yarn.lock b/yarn.lock index f7e29fa..c7ca420 100644 --- a/yarn.lock +++ b/yarn.lock @@ -116,6 +116,13 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" +"@rollup/plugin-alias@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.1.tgz#bb96cf37fefeb0a953a6566c284855c7d1cd290c" + integrity sha512-hNcQY4bpBUIvxekd26DBPgF7BT4mKVNDF5tBG4Zi+3IgwLxGYRY0itHs9D0oLVwXM5pvJDWJlBQro+au8WaUWw== + dependencies: + slash "^3.0.0" + "@rollup/plugin-commonjs@^14.0.0": version "14.0.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz#4285f9ec2db686a31129e5a2b415c94aa1f836f0" @@ -142,7 +149,7 @@ magic-string "^0.25.7" resolve "^1.17.0" -"@rollup/plugin-json@^4.0.3": +"@rollup/plugin-json@^4.0.3", "@rollup/plugin-json@^4.1.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3" integrity sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==