Skip to content

Commit d9468d3

Browse files
committed
Add TS loader
1 parent aff2c66 commit d9468d3

File tree

4 files changed

+141
-6
lines changed

4 files changed

+141
-6
lines changed

cli/gulpfile.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,21 @@ const script = ({src, name, mode}, done = _ => true) => {
4949
devtool: isProd ? undefined : 'cheap-source-map',
5050
// allow TS importing
5151
resolve: {
52-
extensions: ['.ts', '...']
52+
extensions: ['.ts', '.tsx', '...']
5353
},
54+
// use ts-loader to compile TS files
55+
module: {
56+
rules: [
57+
// all files with a `.ts`, `.cts`, `.mts` or `.tsx` extension will be handled by `ts-loader`
58+
{
59+
test: /\.([cm]?ts|tsx)$/,
60+
loader: 'ts-loader',
61+
options: {
62+
configFile: 'src/tsconfig.json'
63+
}
64+
}
65+
]
66+
}
5467
};
5568

5669
return gulp.src(src)

guide/03-xt-build.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ xt-build {-e|--env} dev {-w|--watch}
6969
xt-build --help
7070
```
7171

72+
## TypeScript notes
73+
74+
You may use either TypeScript (`.ts`, `.tsx`) or JavaScript files. However, if any TypeScript is used, you must add
75+
`tsconfig.json` to the `src` directory.
76+
77+
In this config file, you do not need to add anything (unless you want to change any settings). However, without it,
78+
compilation will fail.
79+
7280
## Package.json scripts
7381

7482
After adding Extension CLI to your project, you can run these commands from a

package-lock.json

Lines changed: 118 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"sass": "1.49.9",
103103
"sinon": "13.0.1",
104104
"sinon-chrome": "3.0.1",
105+
"ts-loader": "9.5.0",
105106
"webpack-stream": "7.0.0",
106107
"yargs": "17.3.1"
107108
},

0 commit comments

Comments
 (0)