build: refactor compile script

This commit is contained in:
chenshenhai 2022-04-28 23:46:07 +08:00
parent a334b278f3
commit 3ce13d3595
76 changed files with 32 additions and 36 deletions

View file

@ -23,7 +23,7 @@ async function diff() {
const height = p.h;
await page.setViewport( { width: p.w, height: p.h } );
const pageUrl = `http://127.0.0.1:${port}/packages/${p.path || ''}`;
const pageUrl = `http://127.0.0.1:${port}/examples/${p.path || ''}`;
await page.goto(pageUrl);
await delay(p.delay || 100);
const buf = await page.screenshot();

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View file

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View file

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View file

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View file

Before

Width:  |  Height:  |  Size: 762 KiB

After

Width:  |  Height:  |  Size: 762 KiB

View file

Before

Width:  |  Height:  |  Size: 384 KiB

After

Width:  |  Height:  |  Size: 384 KiB

View file

Before

Width:  |  Height:  |  Size: 274 KiB

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View file

@ -59,7 +59,7 @@
<button id="reset-cursor">Reset cursor</button>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/board/dist/index.global.js"></script>
<script type="module" src="./main.js"></script>
<script>
// console.log(parent.window.location);

View file

@ -61,7 +61,7 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/board/dist/index.global.js"></script>
<script>
var opts = {
width: 300,
@ -108,7 +108,7 @@
</script>
<script type="module">
import event from './../../../../scripts/browser/event.js';
import event from './../../../scripts/browser/event.js';
(async function() {
const { Board } = window.iDrawBoard;
const mount1 = document.querySelector('#mount-1');

View file

@ -51,7 +51,7 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/board/dist/index.global.js"></script>
<script>
function drawBoard(board) {

View file

@ -60,7 +60,7 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/board/dist/index.global.js"></script>
<script>
function drawBoard(board) {

View file

@ -51,7 +51,7 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/board/dist/index.global.js"></script>
<script>
var opts = {
width: 300,
@ -126,7 +126,7 @@
</script>
<script type="module">
import event from './../../../../scripts/browser/event.js';
import event from '../../../scripts/browser/event.js';
(function() {
const { Board } = window.iDrawBoard;
const mount = document.querySelector('#mount-2');

View file

@ -31,7 +31,7 @@
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/core/dist/index.global.js"></script>
<script type="module" src="./lib/main.js"></script>
</body>
</html>

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 222 KiB

View file

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

View file

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 124 KiB

View file

@ -99,9 +99,9 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/core/dist/index.global.js"></script>
<script type="module">
import event from './../../../../scripts/browser/event.js';
import event from '../../../scripts/browser/event.js';
import { getData } from './data.js';
window.event = event;
window.getData = getData;

View file

@ -72,9 +72,9 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/core/dist/index.global.js"></script>
<script type="module">
import event from './../../../../scripts/browser/event.js';
import event from '../../../scripts/browser/event.js';
import { getData } from './data.js';
window.event = event;
window.getData = getData;

View file

@ -48,7 +48,7 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/core/dist/index.global.js"></script>
<script>
const { Core } = window.iDrawCore;
var opts = {

View file

@ -65,7 +65,7 @@
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/core/dist/index.global.js"></script>
<script>
const { Core } = window.iDrawCore;
var opts = {

View file

@ -42,7 +42,7 @@
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/idraw/dist/index.global.js"></script>
<script type="module" src="./lib/main.js"></script>
</body>
</html>

View file

@ -63,7 +63,7 @@
</div>
</div>
<script src="./../../dist/index.global.js"></script>
<script src="../../../packages/idraw/dist/index.global.js"></script>
<script>
const testData = {
bgColor: "#ffffff",

View file

@ -11,8 +11,8 @@
<canvas id="canvas"></canvas>
</div>
<script src="./../../util/dist/index.global.js"></script>
<script src="./../dist/index.global.js"></script>
<script src="../../../packages/util/dist/index.global.js"></script>
<script src="../../../packages/renderer/dist/index.global.js"></script>
<script type="module" src="./lib/main.js"></script>
</body>
</html>

View file

@ -2,13 +2,13 @@
"name": "root",
"private": false,
"scripts": {
"start": "node ./scripts/dev-vite.js",
"dev": "node ./scripts/dev-rollup.js",
"dev": "node ./scripts/dev.js",
"dev:rollup": "node ./scripts/dev-rollup.js",
"build": "npm run build:mod && npm run build:bundle && npm run build:min",
"build:bundle": "NODE_ENV=production BUILD_MODE=reset node ./scripts/build-bundle.js",
"build:mod": "node ./scripts/build-module.js",
"build:min": "node ./scripts/minify.js",
"snapshot": "node ./scripts/build.js && node ./scripts/snapshot.js",
"snapshot": "npm run build:bundle && node ./scripts/snapshot.js",
"e2e": "mocha --exit ./__tests__/e2e.test.js",
"init": "lerna bootstrap",
"init:cnpm": "lerna bootstrap --npm-client=cnpm",

View file

@ -25,7 +25,6 @@ async function main() {
[
'-c',
'./scripts/rollup.config.js',
`--target-pkg=${process.argv[2] || ''}`,
], { stdio: 'inherit' });
}

View file

@ -9,7 +9,6 @@ async function main() {
'-w',
'-c',
'./scripts/rollup.config.js',
`--target-pkg=${process.argv[2] || ''}`,
], { stdio: 'inherit' }
)
}

View file

@ -5,7 +5,7 @@ const { terser } = require('rollup-plugin-terser');
const cleanup = require('rollup-plugin-cleanup');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const json = require('@rollup/plugin-json');
const { getTargetPackage } = require('./config');
const { packages } = require('./config');
const dtsPlugin = require('./util/dts-plugin');
const stylePlugin = require('./util/style-plugin');
// const cleanPlugin = require('./util/clean-plugin');
@ -13,8 +13,6 @@ const stylePlugin = require('./util/style-plugin');
const resolveFile = function(names = []) {
return path.join(__dirname, '..', 'packages', ...names)
}
const targetMod = process.argv[5] || process.argv[4];
const packages = getTargetPackage(targetMod);
const modules = [];
const external = [ '@idraw/types', '@idraw/util', '@idraw/board', '@idraw/core' ];

View file

@ -1,12 +1,12 @@
const pageList = [
{ path: 'board/examples/test/main.html', w: 620, h: 270, delay: 500 },
{ path: 'board/examples/test/scale.html', w: 930, h: 540, delay: 500 },
{ path: 'board/examples/test/scroll.html', w: 620, h: 270, delay: 500 },
{ path: 'board/examples/test/event.html', w: 620, h: 270, delay: 500 },
{ path: 'core/examples/test/elements.html', w: 930, h: 810, delay: 800 },
{ path: 'core/examples/test/api.html', w: 930, h: 1570, delay: 800 },
{ path: 'core/examples/test/resource.html', w: 930, h: 540, delay: 800 },
{ path: 'idraw/examples/test/api.html', w: 930, h: 540, delay: 800 },
{ path: 'board/test/main.html', w: 620, h: 270, delay: 500 },
{ path: 'board/test/scale.html', w: 930, h: 540, delay: 500 },
{ path: 'board/test/scroll.html', w: 620, h: 270, delay: 500 },
{ path: 'board/test/event.html', w: 620, h: 270, delay: 500 },
{ path: 'core/test/elements.html', w: 930, h: 810, delay: 800 },
{ path: 'core/test/api.html', w: 930, h: 1570, delay: 800 },
{ path: 'core/test/resource.html', w: 930, h: 540, delay: 800 },
{ path: 'idraw/test/api.html', w: 930, h: 540, delay: 800 },
]
module.exports = {

View file

@ -17,7 +17,7 @@ async function main() {
const { page, port } = ctx;
console.log(`[${i+1}/${pageList.length}] Screen: ${p.path}`)
await page.setViewport( { width: p.w, height: p.h } );
const pageUrl = `http://127.0.0.1:${port}/packages/${p.path || ''}`;
const pageUrl = `http://127.0.0.1:${port}/examples/${p.path || ''}`;
const result = await page.goto(pageUrl);
if (result.status() === 404) {
console.error(`404 Not Found: ${pageUrl}`)