Skip to content

Commit 229053a

Browse files
authored
Merge pull request #359 from HerringtonDarkholme/dev
add documentation for appendTsSuffixTo
2 parents c7f5773 + f70d321 commit 229053a

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A full test suite runs each night (and on each pull request). It runs both on Li
2121
- TypeScript 1.7
2222
- TypeScript 1.6
2323

24-
and also:
24+
and also:
2525
- TypeScript@next (because we want to use it as much as you do)
2626

2727
If you become aware of issues not caught by the test suite then please let us know. Better yet, write a test and submit it in a PR!
@@ -157,7 +157,7 @@ messages are emitted via webpack which is not affected by this flag.
157157
##### ignoreDiagnostics *(number[]) (default=[])*
158158

159159
You can squelch certain TypeScript errors by specifying an array of diagnostic
160-
codes to ignore.
160+
codes to ignore.
161161

162162
##### compiler *(string) (default='typescript')*
163163

@@ -179,6 +179,51 @@ Advanced option to force files to go through different instances of the
179179
TypeScript compiler. Can be used to force segregation between different parts
180180
of your code.
181181

182+
183+
#### appendTsSuffixTo *(RegExp[]) (default=[])*
184+
A list of regular expression to be matched against filename. If filename matches one of the regular expressions, a `.ts` suffix will be appended to that filename.
185+
186+
This is useful for `*.vue` [file format](https://vuejs.org/v2/guide/single-file-components.html) for now. (Probably will benefits new single file format.)
187+
188+
Example:
189+
190+
webpack.config.js:
191+
192+
```javascript
193+
module.exports = {
194+
entry: './index.vue',
195+
output: { filename: 'bundle.js' },
196+
resolve: {
197+
extensions: ['', '.ts', '.vue']
198+
},
199+
module: {
200+
loaders: [
201+
{ test: /\.vue$/, loader: 'vue' },
202+
{ test: /\.ts$/, loader: 'ts' }
203+
]
204+
},
205+
ts: {
206+
appendTsSuffixTo: [/\.vue$/]
207+
}
208+
}
209+
```
210+
211+
index.vue
212+
213+
```vue
214+
<template><p>hello {{msg}}</p></template>
215+
<script lang="ts">
216+
export default {
217+
data(): Object {
218+
return {
219+
msg: "world"
220+
}
221+
},
222+
}
223+
</script>
224+
```
225+
226+
182227
### Loading other resources and code splitting
183228

184229
Loading css and other resources is possible but you will need to make sure that

0 commit comments

Comments
 (0)