aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-10 12:45:44 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-10 13:04:18 +0800
commit89ca84e47d4958e064b682405e94a3270fc99338 (patch)
treef01c5fb25e5fd4f25db874c371244c0c92d50a5b /scripts
parenteaf2639b3c9269b9222bfcd993b7b7a3980f1b2a (diff)
chore: move config files about dev into scripts/
Diffstat (limited to 'scripts')
-rw-r--r--scripts/rollup.config.js63
-rwxr-xr-xscripts/stylelint.sh2
-rw-r--r--scripts/stylelintrc.json130
3 files changed, 194 insertions, 1 deletions
diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js
new file mode 100644
index 0000000..d4af05f
--- /dev/null
+++ b/scripts/rollup.config.js
@@ -0,0 +1,63 @@
1import node from '@rollup/plugin-node-resolve'
2import commonjs from '@rollup/plugin-commonjs'
3import terser from '@rollup/plugin-terser'
4import { existsSync } from 'fs'
5import { join } from 'path'
6import { bundleStats } from 'rollup-plugin-bundle-stats'
7
8const production = !process.env.ROLLUP_WATCH
9
10const general = {
11 output: [
12 {
13 dir: './dist',
14 format: 'esm',
15 entryFileNames: '[name].mjs',
16 sourcemap: 'true',
17 },
18 ],
19 watch: {
20 clearScreen: false,
21 include: ['src/**', 'node_modules/mapclay/dist/mapclay.mjs'],
22 },
23 context: 'window',
24 plugins: [
25 {
26 name: 'watch-mapclay',
27 buildStart () {
28 const mapclayPath = join(process.cwd(), 'node_modules', 'mapclay', 'dist', 'mapclay.mjs')
29 if (existsSync(mapclayPath)) {
30 this.addWatchFile(mapclayPath)
31 } else {
32 console.warn('mapclay.mjs not found at:', mapclayPath)
33 }
34 },
35 },
36 {
37 name: 'leader-line',
38 transform (code, id) {
39 if (id.includes('node_modules/leader-line/')) {
40 return `${code}\nexport default LeaderLine;`
41 }
42 return null
43 },
44 },
45 node(),
46 commonjs(),
47 production && terser({
48 keep_fnames: true,
49 }),
50 production && bundleStats(),
51 ],
52}
53
54export default [
55 {
56 input: 'src/editor.mjs',
57 },
58 {
59 input: 'src/dumbymap.mjs',
60 },
61]
62 .map(config => ({ ...general, ...config }))
63 .filter((config) => production || config.input.match(/editor/))
diff --git a/scripts/stylelint.sh b/scripts/stylelint.sh
index 91561de..c44d00b 100755
--- a/scripts/stylelint.sh
+++ b/scripts/stylelint.sh
@@ -1,4 +1,4 @@
1#! /bin/bash 1#! /bin/bash
2 2
3shopt -s extglob 3shopt -s extglob
4stylelint src/css/!(easymde.min.css) --fix 4stylelint -c scripts/stylelintrc.json src/css/!(easymde.min.css) --fix
diff --git a/scripts/stylelintrc.json b/scripts/stylelintrc.json
new file mode 100644
index 0000000..6e8978b
--- /dev/null
+++ b/scripts/stylelintrc.json
@@ -0,0 +1,130 @@
1{
2 "extends": [
3 "stylelint-config-standard"
4 ],
5 "plugins": [
6 "stylelint-order"
7 ],
8 "rules": {
9 "at-rule-no-vendor-prefix": true,
10 "color-hex-length": "short",
11 "color-named": "always-where-possible",
12 "comment-whitespace-inside": "always",
13 "custom-property-empty-line-before": "never",
14 "declaration-block-single-line-max-declarations": 1,
15 "declaration-empty-line-before": null,
16 "font-family-name-quotes": "always-where-required",
17 "no-duplicate-selectors": true,
18 "property-no-vendor-prefix": true,
19 "selector-attribute-quotes": "always",
20 "selector-class-pattern": null,
21 "selector-no-vendor-prefix": true,
22 "value-no-vendor-prefix": true,
23 "order/order": [
24 "custom-properties",
25 "dollar-variables",
26 "declarations",
27 "rules",
28 "at-rules"
29 ],
30 "order/properties-order": [
31 {
32 "groupName": "Display & Box Model",
33 "emptyLineBefore": "always",
34 "noEmptyLineBetween": true,
35 "properties": [
36 "content",
37 "display",
38 "box-sizing",
39 "overflow",
40 "flex",
41 "flex-direction",
42 "justify-content",
43 "align-items",
44 "width",
45 "min-width",
46 "max-width",
47 "height",
48 "min-height",
49 "max-height",
50 "margin",
51 "margin-top",
52 "margin-right",
53 "margin-bottom",
54 "margin-left",
55 "padding",
56 "padding-block",
57 "padding-inline",
58 "padding-top",
59 "padding-right",
60 "padding-bottom",
61 "padding-left"
62 ]
63 },
64 {
65 "groupName": "Positioning",
66 "emptyLineBefore": "always",
67 "noEmptyLineBetween": true,
68 "properties": [
69 "position",
70 "left",
71 "top",
72 "right",
73 "bottom",
74 "z-index"
75 ]
76 },
77 {
78 "groupName": "Border",
79 "emptyLineBefore": "always",
80 "noEmptyLineBetween": true,
81 "properties": [
82 "border",
83 "border-top",
84 "border-right",
85 "border-bottom",
86 "border-left",
87 "border-radius"
88 ]
89 },
90 {
91 "groupName": "Background",
92 "emptyLineBefore": "always",
93 "noEmptyLineBetween": true,
94 "properties": [
95 "background",
96 "background-color",
97 "background-image",
98 "background-repeat",
99 "background-position"
100 ]
101 },
102 {
103 "groupName": "Typography",
104 "emptyLineBefore": "always",
105 "noEmptyLineBetween": true,
106 "properties": [
107 "color",
108 "font-family",
109 "font-size",
110 "font-weight",
111 "line-height",
112 "text-align",
113 "text-transform"
114 ]
115 },
116 {
117 "groupName": "Visual",
118 "emptyLineBefore": "always",
119 "noEmptyLineBetween": true,
120 "properties": [
121 "transition",
122 "transform",
123 "visibility",
124 "opacity",
125 "cursor"
126 ]
127 }
128 ]
129 }
130}