/
TypeScript.js
45 lines (39 loc) · 1009 Bytes
/
TypeScript.js
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
let JavaScript = require('./JavaScript');
class TypeScript extends JavaScript {
/**
* The API name for the component.
*/
name() {
return ['typeScript', 'ts'];
}
/**
* Required dependencies for the component.
*/
dependencies() {
return ['ts-loader', 'typescript'].concat();
}
/**
* webpack rules to be appended to the master config.
*/
webpackRules() {
return [].concat(super.webpackRules(), {
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/]
}
});
}
/**
* Override the generated webpack configuration.
*
* @param {Object} config
*/
webpackConfig(config) {
super.webpackConfig(config);
config.resolve.extensions.push('.ts', '.tsx');
config.resolve.alias['vue$'] = 'vue/dist/vue.esm.js';
}
}
module.exports = TypeScript;