|
| 1 | +module.exports = api => { |
| 2 | + api.chainWebpack(config => { |
| 3 | + config.entry('app') |
| 4 | + .clear() |
| 5 | + .add('./src/main.ts') |
| 6 | + |
| 7 | + config.resolve |
| 8 | + .extensions |
| 9 | + .merge(['.ts', '.tsx']) |
| 10 | + |
| 11 | + config.module |
| 12 | + .rule('ts') |
| 13 | + .test(/\.tsx?$/) |
| 14 | + .include |
| 15 | + .add(api.resolve('src')) |
| 16 | + .end() |
| 17 | + .use('ts-loader') |
| 18 | + .loader('ts-loader') |
| 19 | + .options({ |
| 20 | + transpileOnly: true, |
| 21 | + appendTsSuffixTo: [/\.vue$/] |
| 22 | + }) |
| 23 | + |
| 24 | + config |
| 25 | + .plugin('fork-ts-checker') |
| 26 | + .use(require('fork-ts-checker-webpack-plugin'), [{ |
| 27 | + vue: true, |
| 28 | + tslint: true, |
| 29 | + formatter: 'codeframe' |
| 30 | + }]) |
| 31 | + }) |
| 32 | + |
| 33 | + api.registerCommand('lint', { |
| 34 | + descriptions: 'lint source files with TSLint', |
| 35 | + usage: 'vue-cli-service lint [options] [...files]', |
| 36 | + options: { |
| 37 | + '--format': 'specify formatter (default: codeframe)', |
| 38 | + '--no-fix': 'do not fix errors' |
| 39 | + }, |
| 40 | + details: 'For more options, see https://palantir.github.io/tslint/usage/cli/' |
| 41 | + }, (args) => { |
| 42 | + const { run } = require('tslint/lib/runner') |
| 43 | + |
| 44 | + return run({ |
| 45 | + files: args._ && args._.length ? args._ : ['src/**/*.ts'], |
| 46 | + exclude: args.exclude || [], |
| 47 | + fix: !args['no-fix'], |
| 48 | + project: api.resolve('tsconfig.json'), |
| 49 | + config: api.resolve('tslint.json'), |
| 50 | + force: args.force, |
| 51 | + format: args.format, |
| 52 | + formattersDirectory: args['formatters-dir'], |
| 53 | + init: args.init, |
| 54 | + out: args.out, |
| 55 | + outputAbsolutePaths: args['output-absolute-paths'], |
| 56 | + rulesDirectory: args['rules-dir'], |
| 57 | + test: args.test, |
| 58 | + typeCheck: args['type-check'] |
| 59 | + }, { |
| 60 | + log (m) { process.stdout.write(m) }, |
| 61 | + error (m) { process.stdout.write(m) } |
| 62 | + }).then(code => { |
| 63 | + process.exitCode = code |
| 64 | + }).catch(err => { |
| 65 | + console.error(err) |
| 66 | + process.exitCode = 1 |
| 67 | + }) |
| 68 | + }) |
| 69 | +} |
0 commit comments