diff --git a/package.json b/package.json index 7d5abaf7..5f8f657f 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,10 @@ "watch": "yarn compile -w", "clean": "rm -rf lib/*", "compile": "rollup -c", + "clean:fixture": "rm -rf dist/ test/fixture/.nuxt", "fixture": "yarn nuxt-run dev", - "fixture:prod": "rm -rf .nuxt && yarn nuxt-run build && yarn nuxt-run start", - "fixture:generate:export": "export GENERATE=true && rm -rf .nuxt && yarn nuxt-run build && PORT=6000 yarn nuxt-run export", + "fixture:prod": "yarn clean:fixture && yarn nuxt-run build && yarn nuxt-run start", + "fixture:generate:export": "yarn clean:fixture && export GENERATE=true && yarn nuxt-run build && PORT=6000 yarn nuxt-run export", "fixture:generate": "yarn fixture:generate:export && yarn http-server -s -p 5000 dist", "lint": "run-s lint:all:*", "lint:all:eslint": "yarn lint:eslint --ext .js,.ts,.vue .", diff --git a/src/index.ts b/src/index.ts index 2c87f1e3..8ff992f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { resolve, join } from 'path' -import { rmdirSync, readdirSync, copyFileSync, existsSync, mkdirSync } from 'fs' +import { readdirSync, copyFileSync, existsSync, mkdirpSync } from 'fs-extra' import type { Module } from '@nuxt/types' @@ -28,9 +28,8 @@ const compositionApiModule: Module = function () { const staticPath = join(this.options.buildDir || '', 'static-json') - this.nuxt.hook('generate:before', () => { - if (existsSync(staticPath)) rmdirSync(staticPath) - mkdirSync(staticPath) + this.nuxt.hook('generate:route', () => { + mkdirpSync(staticPath) }) this.nuxt.hook('generate:done', async (generator: any) => {