Skip to content

Commit 7f3380e

Browse files
committed
feat(build): skip legacy build with @vue/cli-service v3.4.1+
1 parent 2a8a080 commit 7f3380e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

__tests__/commands.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ describe('electron:build', () => {
203203
fs.existsSync.mockReturnValueOnce(true)
204204
await runCommand('electron:build')
205205
// css/fonts folder was created
206-
expect(fs.ensureDirSync.mock.calls[1][0]).toBe(
206+
expect(fs.ensureDirSync.mock.calls[2][0]).toBe(
207207
'projectPath/dist_electron/bundled/css/fonts'
208208
)
209209
// fonts was copied to css/fonts

index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,27 @@ module.exports = (api, options) => {
9494
// Build with electron-builder
9595
buildApp()
9696
} else {
97+
const bundleOutputDir = path.join(outputDir, 'bundled')
9798
// Arguments to be passed to renderer build
9899
const vueArgs = {
99100
_: [],
100101
// For the cli-ui webpack dashboard
101102
dashboard: args.dashboard,
102103
// Make sure files are outputted to proper directory
103-
dest: outputDir + '/bundled',
104+
dest: bundleOutputDir,
104105
// Enable modern mode unless --legacy is passed
105106
modern: !args.legacy
106107
}
108+
// With @vue/cli-service v3.4.1+, we can bypass legacy build
109+
process.env.VUE_CLI_MODERN_BUILD = !args.legacy
110+
// If the legacy builded is skipped the output dir won't be cleaned
111+
fs.removeSync(bundleOutputDir)
112+
fs.ensureDirSync(bundleOutputDir)
113+
// Mock data from legacy build
114+
fs.writeFileSync(
115+
path.join(bundleOutputDir, 'legacy-assets-index.html.json'),
116+
'[]'
117+
)
107118
// Set the base url so that the app protocol is used
108119
options.baseUrl = pluginOptions.customFileProtocol || 'app://./'
109120
// Set publicPath as well (replaced baseUrl since @vue/cli 3.3.0)

0 commit comments

Comments
 (0)