-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathclean-scripts.config.ts
77 lines (70 loc) · 2.87 KB
/
clean-scripts.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { executeScriptAsync } from 'clean-scripts'
import { watch } from 'watch-then-execute'
const tsFiles = `"packages/@(core|vue|react)/@(src|demo)/**/*.@(ts|tsx)"`
const lessFiles = `"packages/core/src/**/*.less"`
const excludeTsFiles = `"packages/@(core|vue|react)/@(src|demo)/**/*.@(d|config).ts"`
const vueTemplateCommand = `file2variable-cli --config packages/vue/src/file2variable.config.ts`
const tscCoreSrcCommand = `tsc -p packages/core/src`
const tscVueSrcCommand = `tsc -p packages/vue/src`
const tscReactSrcCommand = `tsc -p packages/react/src`
const webpackVueCommand = `webpack --config packages/vue/demo/webpack.config.ts`
const webpackReactCommand = `webpack --config packages/react/demo/webpack.config.ts`
const revStaticCommand = `rev-static`
const cssCommand = [
`lessc packages/core/src/select2.less --math=strict > packages/core/src/select2.css`,
`postcss packages/core/src/select2.css -o packages/core/dist/select2.css`,
`cleancss packages/core/dist/select2.css -o packages/core/dist/select2.min.css`,
`cleancss packages/core/dist/select2.min.css ./node_modules/github-fork-ribbon-css/gh-fork-ribbon.css -o packages/core/demo/index.bundle.css`
]
const isDev = process.env.NODE_ENV === 'development'
export default {
build: [
{
js: [
tscCoreSrcCommand,
{
vue: [
vueTemplateCommand,
tscVueSrcCommand,
isDev ? undefined : `rollup --config packages/vue/src/rollup.config.js`,
webpackVueCommand
],
react: [
tscReactSrcCommand,
isDev ? undefined : `rollup --config packages/react/src/rollup.config.js`,
webpackReactCommand
]
}
],
css: cssCommand,
clean: `rimraf "packages/@(core|vue|react)/demo/**/@(*.bundle-*.js|*.bundle-*.css)"`
},
revStaticCommand
],
lint: {
ts: `eslint --ext .js,.ts ${tsFiles}`,
less: `stylelint ${lessFiles}`,
export: `no-unused-export ${tsFiles} ${lessFiles} --exclude ${excludeTsFiles}`,
markdown: `markdownlint README.md`,
typeCoverage: {
core: 'cd packages/core && type-coverage -p src --strict',
vue: 'cd packages/vue && type-coverage -p src --strict --ignore-files "src/variables.ts"',
react: 'cd packages/react && type-coverage -p src --strict'
}
},
test: [],
fix: {
ts: `eslint --ext .js,.ts ${tsFiles} --fix`,
less: `stylelint --fix ${lessFiles}`
},
watch: {
vueTemplateCommand: `${vueTemplateCommand} --watch`,
tscCoreSrcCommand: `${tscCoreSrcCommand} --watch`,
tscVueSrcCommand: `${tscVueSrcCommand} --watch`,
tscReactSrcCommand: `${tscReactSrcCommand} --watch`,
webpackVueCommand: `${webpackVueCommand} --watch`,
webpackReactCommand: `${webpackReactCommand} --watch`,
less: () => watch(['src/**/*.less'], [], () => executeScriptAsync(cssCommand)),
rev: `${revStaticCommand} --watch`
}
}