File tree Expand file tree Collapse file tree 4 files changed +1132
-4
lines changed Expand file tree Collapse file tree 4 files changed +1132
-4
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ Additionally, you can add it to your build scripts
44
44
"name" : " myproject" ,
45
45
"version" : " 0.1.0" ,
46
46
"scripts" : {
47
- "dev" : " etsc"
47
+ "dev" : " etsc"
48
48
}
49
49
}
50
50
```
@@ -122,7 +122,15 @@ module.exports = {
122
122
};
123
123
```
124
124
125
- All of the above fields are optional
125
+ All of the above fields are optional.
126
+
127
+ If you want to use different config files for different types of builds you can do so using the param ` --config ` . Example:
128
+
129
+ ```
130
+ "scripts": {
131
+ "build": "etsc --config=etsc.config.build.js"
132
+ }
133
+ ```
126
134
127
135
## License
128
136
Original file line number Diff line number Diff line change 24
24
"devDependencies" : {
25
25
"@types/node" : " ^14.6.4" ,
26
26
"@types/rimraf" : " ^3.0.0" ,
27
+ "@types/yargs" : " ^16.0.1" ,
27
28
"typescript" : " ^4.0.2"
28
29
},
29
30
"dependencies" : {
30
31
"cpy" : " ^8.1.1" ,
31
32
"esbuild" : " ^0.8.34" ,
32
- "rimraf" : " ^3.0.2"
33
+ "rimraf" : " ^3.0.2" ,
34
+ "yargs" : " ^16.2.0"
33
35
},
34
36
"peerDependencies" : {
35
37
"typescript" : " *"
Original file line number Diff line number Diff line change @@ -5,9 +5,13 @@ import { build } from "esbuild";
5
5
import cpy from "cpy" ;
6
6
import path from "path" ;
7
7
import rimraf from "rimraf" ;
8
+ import yargs from 'yargs/yargs' ;
9
+ import { hideBin } from 'yargs/helpers' ;
10
+ import { Argv } from 'yargs' ;
8
11
import { Config , readUserConfig } from "./config" ;
9
12
10
13
const cwd = process . cwd ( ) ;
14
+ const { argv } = yargs ( hideBin ( process . argv ) ) ;
11
15
12
16
function getTSConfig ( _tsConfigFile = "tsconfig.json" ) {
13
17
const tsConfigFile = ts . findConfigFile ( cwd , ts . sys . fileExists , _tsConfigFile ) ;
@@ -104,7 +108,9 @@ async function copyNonSourceFiles({
104
108
}
105
109
106
110
async function main ( ) {
107
- const config = await readUserConfig ( path . resolve ( cwd , "etsc.config.js" ) ) ;
111
+ const configFilename = < string > argv?.config || 'etsc.config.js';
112
+
113
+ const config = await readUserConfig(path.resolve(cwd, configFilename));
108
114
109
115
const { outDir , esbuildOptions , assetsOptions } = getBuildMetadata(config);
110
116
You can’t perform that action at this time.
0 commit comments