-
Notifications
You must be signed in to change notification settings - Fork 94
/
index.js
42 lines (39 loc) · 1.04 KB
/
index.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
/**
* Typescript webpack block.
*
* @see https://github.com/s-panferov/awesome-typescript-loader
*/
const { CheckerPlugin, TsConfigPathsPlugin } = require('awesome-typescript-loader')
module.exports = typescript
/**
* @param {object} [options] See https://github.com/s-panferov/awesome-typescript-loader#loader-options
* @return {Function}
*/
function typescript(options = {}) {
return (context, util) =>
util.merge({
resolve: {
extensions: ['.ts', '.tsx']
},
module: {
rules: [
Object.assign(
{
test: /\.(ts|tsx)$/,
use: [
{
loader: 'awesome-typescript-loader',
options
}
]
},
context.match
)
]
},
plugins: [
new CheckerPlugin(),
new TsConfigPathsPlugin({ tsconfig: options.configFileName, compiler: options.compiler }) // This hooks into webpacks module resolution, configure via tsconfig.json
]
})
}