Browse Source

fix: npm postinstall script

master
Hans Chan 4 years ago
parent
commit
c97055d903
  1. 2
      example/package.json
  2. 2
      package.json
  3. 1
      packages/cli/package.json
  4. 8
      packages/cli/src/cmd/editor/build.js

2
example/package.json

@ -2,7 +2,7 @@
"name": "example", "name": "example",
"scripts": { "scripts": {
"start": "umi dev", "start": "umi dev",
"build": "umi build", "build": "",
"postinstall": "umi generate tmp" "postinstall": "umi generate tmp"
}, },
"dependencies": { "dependencies": {

2
package.json

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

1
packages/cli/package.json

@ -11,6 +11,7 @@
"compile" "compile"
], ],
"scripts": { "scripts": {
"build": "",
"build:editor": "node src/cmd/editor/build.js", "build:editor": "node src/cmd/editor/build.js",
"postinstall": "npm run build:editor" "postinstall": "npm run build:editor"
}, },

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

@ -2,15 +2,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path'); const path = require('path');
const fs = require('fs-extra');
const { lessLoader } = require('esbuild-plugin-less'); const { lessLoader } = require('esbuild-plugin-less');
// 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 // build js and css for editor
const OUT_FILE = path.join(__dirname, 'template/dist/app.bundle.js'); const OUT_FILE = path.join(__dirname, 'template/dist/app.bundle.js');
require('esbuild') require('esbuild')
@ -19,6 +12,7 @@ require('esbuild')
entryPoints: [path.join(__dirname, 'template/app.jsx')], entryPoints: [path.join(__dirname, 'template/app.jsx')],
outfile: OUT_FILE, outfile: OUT_FILE,
plugins: [ plugins: [
// fix multi-react with lerna
{ {
name: 'resolve-multi-react', name: 'resolve-multi-react',
setup: (build) => { setup: (build) => {

Loading…
Cancel
Save