diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js index 12381d7079..6c6ebfdca7 100644 --- a/packages/config/src/config/build.js +++ b/packages/config/src/config/build.js @@ -43,6 +43,10 @@ export default () => ({ }, scss: {}, stylus: {}, + ts: { + transpileOnly: true, + appendTsSuffixTo: [/\.vue$/] + }, vueStyle: {} }, styleResources: {}, diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js index 8c1e735b49..c36ab9a2e9 100644 --- a/packages/webpack/src/config/base.js +++ b/packages/webpack/src/config/base.js @@ -233,10 +233,7 @@ export default class WebpackBaseConfig { { test: /\.ts$/, loader: 'ts-loader', - options: { - transpileOnly: true, - appendTsSuffixTo: [/\.vue$/] - } + options: this.loaders.ts }, { test: /\.css$/, diff --git a/test/unit/basic.dev.test.js b/test/unit/basic.dev.test.js index 58f2c26550..11abad01a0 100644 --- a/test/unit/basic.dev.test.js +++ b/test/unit/basic.dev.test.js @@ -80,10 +80,10 @@ describe('basic dev', () => { }) test('Config: build.loaders', () => { - expect(Object.keys(loadersOptions)).toHaveLength(12) + expect(Object.keys(loadersOptions)).toHaveLength(13) expect(loadersOptions).toHaveProperty( 'file', 'fontUrl', 'imgUrl', 'pugPlain', 'vue', - 'css', 'cssModules', 'less', 'sass', 'scss', 'stylus', 'vueStyle' + 'css', 'cssModules', 'less', 'sass', 'scss', 'stylus', 'ts', 'vueStyle' ) const { cssModules, vue } = loadersOptions expect(cssModules.localIdentName).toBe('[hash:base64:6]')