Skip to content

Commit 9a6f06a

Browse files
authored
Switch to esbuild (#126)
* Switch to esbuild * Update build result * Update build instruction in docs
1 parent cbad314 commit 9a6f06a

9 files changed

+55
-6892
lines changed

Makefile

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
# for saving keystrokes
2-
3-
TARGET := ./css-doodle.js
4-
TARGET_MIN := ./css-doodle.min.js
1+
TARGET := ./css-doodle.min.js
52
LIB := ./node_modules
63

7-
all: build minify
4+
all: build minify trim banner
85

96
build: $(LIB)
107
@npm run build
118

129
minify: $(TARGET)
1310
@npm run minify
14-
@./tools/trim.js $(TARGET_MIN)
11+
12+
banner: $(TARGET)
13+
@npm run banner
14+
15+
trim: $(TARGET)
16+
@npm run trim
1517

1618
test:
1719
@npm run test
18-
.PHONY: test
1920

2021
$(LIB):
2122
@npm install
23+
24+
$(TARGET):
25+
@npm run build
26+
27+
.PHONY: $(TARGET) banner test

README.md

-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ A web component for drawing patterns with CSS.
4040
## Build
4141

4242
```bash
43-
# build css-doodle.js
44-
npm run build
45-
46-
# generate css-doodle.min.js
47-
npm run minify
48-
49-
# or just use make
5043
make
5144
```
5245

build/banner.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
3+
import fs from 'fs';
4+
import { fileURLToPath } from 'url';
5+
import { dirname, resolve } from 'path';
6+
7+
const target = process.argv[2];
8+
if (!target) {
9+
console.log('missing <target>');
10+
process.exit(0);
11+
}
12+
13+
const __dirname = dirname(fileURLToPath(import.meta.url));
14+
const file = resolve(__dirname, '../package.json');
15+
const { version } = JSON.parse(fs.readFileSync(file));
16+
const banner = `/*! css-doodle v${version} MIT licensed */\n`
17+
18+
try {
19+
const content = fs.readFileSync(target, 'utf8');
20+
if (content) {
21+
fs.writeFileSync(target, banner + content, 'utf8');
22+
}
23+
} catch (e) {
24+
// it's ok
25+
}

tools/trim.js build/trim.js

File renamed without changes.

0 commit comments

Comments
 (0)