feat(cli): restart compile when vant config updated

This commit is contained in:
陈嘉涵
2019-12-04 18:10:14 +08:00
parent 2db6e2a44d
commit b19b287276
11 changed files with 152 additions and 105 deletions
@@ -0,0 +1,28 @@
import { Compiler } from 'webpack';
import { genPackageEntry } from './gen-package-entry';
import { genPacakgeStyle } from './gen-package-style';
import { genSiteMobileShared } from './gen-site-mobile-shared';
import { genSiteDesktopShared } from './gen-site-desktop-shared';
import { genStyleDepsMap } from './gen-style-deps-map';
const PLUGIN_NAME = 'VantCliSitePlugin';
export class VantCliSitePlugin {
apply(compiler: Compiler) {
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, this.genSiteEntry);
}
genSiteEntry() {
return new Promise((resolve, reject) => {
genStyleDepsMap()
.then(() => {
genPackageEntry();
genPacakgeStyle();
genSiteMobileShared();
genSiteDesktopShared();
resolve();
})
.catch(reject);
});
}
}