Browse Source

fix(cli): build cli with latest core

master
Hans Chan 4 years ago
parent
commit
b47bffdf3c
  1. 6
      .eslintignore
  2. 2
      package.json
  3. 2
      packages/cli/package.json
  4. 27
      packages/cli/src/cmd/editor/build.js

6
.eslintignore

@ -0,0 +1,6 @@
.circleci
.github
.husky
dist/
node_modules/

2
package.json

@ -7,7 +7,7 @@
"doc": "dumi dev",
"start": "concurrently \"lerna run watch --parallel\" \"cross-env APP_ROOT=example umi dev\"",
"example": "concurrently \"lerna run watch --parallel\" \"cross-env APP_ROOT=example umi dev\" \"imove -d\"",
"postinstall": "lerna init && lerna bootstrap && npm link packages/cli",
"postinstall": "npm link packages/cli && lerna init && lerna bootstrap",
"prepare": "husky install"
},
"jest": {

2
packages/cli/package.json

@ -12,7 +12,7 @@
],
"scripts": {
"build:editor": "node src/cmd/editor/build.js",
"prepare": "npm run build:editor"
"postinstall": "npm run build:editor"
},
"repository": {
"type": "git",

27
packages/cli/src/cmd/editor/build.js

@ -1,22 +1,35 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const fs = require('fs-extra');
const { lessLoader } = require('esbuild-plugin-less');
const outfile = path.join(__dirname, 'template/dist/app.bundle.js');
// if builded and NOT force re-build, exit
if (fs.existsSync(outfile) && process.argv.indexOf('--force') < 0) {
console.log('imove editor alredy builded');
return;
// build @imove/core first, if in imove repo
const CORE_DIR = path.join(__dirname, '../../../../core');
if (fs.pathExistsSync(CORE_DIR)) {
require('child_process').execSync(`cd ${CORE_DIR} && rollup -c`);
}
// build js and css for editor
const OUT_FILE = path.join(__dirname, 'template/dist/app.bundle.js');
require('esbuild')
.build({
bundle: true,
entryPoints: [path.join(__dirname, 'template/app.jsx')],
outfile,
outfile: OUT_FILE,
plugins: [
{
name: 'resolve-multi-react',
setup: (build) => {
build.onResolve({ filter: /^react$/, namespace: 'file' }, () => {
return {
path: require.resolve('react'),
watchFiles: undefined,
};
});
},
},
// fix import('antd/dist/antd.less')
{
name: 'resolve-antd-dist-less',

Loading…
Cancel
Save