mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
feat: 重命令某些命令,符合规范
This commit is contained in:
parent
7ea206707b
commit
b3a73ab6c5
@ -3,7 +3,7 @@ import { chokidar, winPath, lodash } from '@umijs/utils';
|
|||||||
import { existsSync, readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs';
|
||||||
import { isPlugin, PluginType } from '@webank/fes-core';
|
import { isPlugin, PluginType } from '@webank/fes-core';
|
||||||
|
|
||||||
function getFesPlugins(opts) {
|
function getPlugins(opts) {
|
||||||
return Object.keys({
|
return Object.keys({
|
||||||
...opts.pkg.dependencies,
|
...opts.pkg.dependencies,
|
||||||
...opts.pkg.devDependencies
|
...opts.pkg.devDependencies
|
||||||
@ -12,7 +12,7 @@ function getFesPlugins(opts) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFesPluginsFromPkgPath(opts) {
|
function getPluginsFromPkgPath(opts) {
|
||||||
let pkg = {};
|
let pkg = {};
|
||||||
if (existsSync(opts.pkgPath)) {
|
if (existsSync(opts.pkgPath)) {
|
||||||
try {
|
try {
|
||||||
@ -21,17 +21,17 @@ function getFesPluginsFromPkgPath(opts) {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getFesPlugins({ pkg });
|
return getPlugins({ pkg });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function watchPkg(opts) {
|
export function watchPkg(opts) {
|
||||||
const pkgPath = join(opts.cwd, 'package.json');
|
const pkgPath = join(opts.cwd, 'package.json');
|
||||||
const plugins = getFesPluginsFromPkgPath({ pkgPath });
|
const plugins = getPluginsFromPkgPath({ pkgPath });
|
||||||
const watcher = chokidar.watch(pkgPath, {
|
const watcher = chokidar.watch(pkgPath, {
|
||||||
ignoreInitial: true
|
ignoreInitial: true
|
||||||
});
|
});
|
||||||
watcher.on('all', () => {
|
watcher.on('all', () => {
|
||||||
const newPlugins = getFesPluginsFromPkgPath({ pkgPath });
|
const newPlugins = getPluginsFromPkgPath({ pkgPath });
|
||||||
if (!lodash.isEqual(plugins, newPlugins)) {
|
if (!lodash.isEqual(plugins, newPlugins)) {
|
||||||
// 已经重启了,只处理一次就够了
|
// 已经重启了,只处理一次就够了
|
||||||
opts.onChange();
|
opts.onChange();
|
||||||
|
@ -21,7 +21,6 @@ export default (api) => {
|
|||||||
]);
|
]);
|
||||||
webpackConfig.module
|
webpackConfig.module
|
||||||
.rule('js-in-node_modules').use('babel-loader').tap((options) => {
|
.rule('js-in-node_modules').use('babel-loader').tap((options) => {
|
||||||
console.log(options);
|
|
||||||
options.cacheDirectory = winPath(`${prefix}/.fes/.cache/babel-loader`);
|
options.cacheDirectory = winPath(`${prefix}/.fes/.cache/babel-loader`);
|
||||||
return options;
|
return options;
|
||||||
});
|
});
|
||||||
|
@ -2,12 +2,12 @@ import { lodash, winPath } from '@umijs/utils';
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
|
||||||
const reserveLibrarys = ['fes']; // reserve library
|
const reserveLibrarys = ['fes']; // reserve library
|
||||||
|
// todo 插件导出内容冲突问题待解决
|
||||||
const reserveExportsNames = [
|
const reserveExportsNames = [
|
||||||
'Link',
|
'Link',
|
||||||
'NavLink',
|
'NavLink',
|
||||||
'Redirect',
|
'Redirect',
|
||||||
'dynamic',
|
'dynamic',
|
||||||
'router',
|
|
||||||
'withRouter',
|
'withRouter',
|
||||||
'Route'
|
'Route'
|
||||||
];
|
];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { createRouter, createWebHashHistory } from '{{{ runtimePath }}}';
|
import { createRouter as createVueRouter, createWebHashHistory } from '{{{ runtimePath }}}';
|
||||||
|
|
||||||
export function getRoutes() {
|
export function getRoutes() {
|
||||||
const routes = {{{ routes }}};
|
const routes = {{{ routes }}};
|
||||||
@ -7,11 +7,11 @@ export function getRoutes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let router = null;
|
let router = null;
|
||||||
export const createHistory = () => {
|
export const createRouter = () => {
|
||||||
if (router) {
|
if (router) {
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
router = createRouter({
|
router = createVueRouter({
|
||||||
history: createWebHashHistory(),
|
history: createWebHashHistory(),
|
||||||
routes: getRoutes()
|
routes: getRoutes()
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
import { plugin } from './core/plugin';
|
import { plugin } from './core/plugin';
|
||||||
import './core/pluginRegister';
|
import './core/pluginRegister';
|
||||||
import { ApplyPluginsType } from '{{{ runtimePath }}}';
|
import { ApplyPluginsType } from '{{{ runtimePath }}}';
|
||||||
import { createRouter } from './core/routes';
|
import { createRouter, getRoutes } from './core/routes';
|
||||||
{{{ imports }}}
|
{{{ imports }}}
|
||||||
|
|
||||||
{{{ entryCodeAhead }}}
|
{{{ entryCodeAhead }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user