diff --git a/packages/remax-cli/package.json b/packages/remax-cli/package.json index db07d4732..4f9c50d2a 100644 --- a/packages/remax-cli/package.json +++ b/packages/remax-cli/package.json @@ -37,6 +37,7 @@ "rollup-plugin-clear": "^2.0.7", "rollup-plugin-commonjs": "^10.0.0", "rollup-plugin-copy": "^3.1.0", + "rollup-plugin-delete": "^1.1.0", "rollup-plugin-json": "^4.0.0", "rollup-plugin-node-resolve": "^5.0.3", "rollup-plugin-progress": "^1.1.1", diff --git a/packages/remax-cli/src/build/rollupConfig.ts b/packages/remax-cli/src/build/rollupConfig.ts index 573fecc80..a25e99265 100644 --- a/packages/remax-cli/src/build/rollupConfig.ts +++ b/packages/remax-cli/src/build/rollupConfig.ts @@ -7,7 +7,7 @@ import url from 'rollup-plugin-url'; import json from 'rollup-plugin-json'; import postcss from '@meck/rollup-plugin-postcss'; import progress from 'rollup-plugin-progress'; -import clear from 'rollup-plugin-clear'; +import clean from 'rollup-plugin-delete'; import alias from 'rollup-plugin-alias'; import copy from 'rollup-plugin-copy'; import stub from './plugins/stub'; @@ -72,6 +72,9 @@ export default function rollupConfig( const cssModuleConfig = getCssModuleConfig(options.cssModules); const plugins = [ + clean({ + targets: ['dist/*', '!.tea'], + }), copy({ targets: [ { @@ -214,14 +217,6 @@ export default function rollupConfig( plugins.push(progress()); } - if (!argv.watch) { - plugins.unshift( - clear({ - targets: options.output, - }) - ); - } - const config: RollupOptions = { input: [entries.app, ...entries.pages.map(p => p.file)], output: { diff --git a/packages/remax-cli/typings/index.d.ts b/packages/remax-cli/typings/index.d.ts index dbcd1bc33..1e2802af0 100644 --- a/packages/remax-cli/typings/index.d.ts +++ b/packages/remax-cli/typings/index.d.ts @@ -3,7 +3,7 @@ declare module '@meck/rollup-plugin-postcss'; declare module 'rollup-plugin-json'; declare module 'rollup-plugin-node-resolve'; declare module 'rollup-plugin-progress'; -declare module 'rollup-plugin-clear'; +declare module 'rollup-plugin-delete'; declare module 'rollup-plugin-alias'; declare module 'rollup-plugin-url'; declare module 'rollup-plugin-typescript';