Skip to content

Commit 3694f3c

Browse files
committedMar 2, 2021
chore: add example support for .vue file extension [skip ci]
1 parent 26697a4 commit 3694f3c

File tree

4 files changed

+226
-5
lines changed

4 files changed

+226
-5
lines changed
 

‎build/tsconfig.webpack.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../tsconfig.json",
33
"include": ["../example"]
4-
}
4+
}

‎build/webpack.config.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const path = require('path');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
4-
4+
const { VueLoaderPlugin } = require('vue-loader');
55
/**
66
* @type { import('webpack').Configuration }
77
*/
@@ -22,6 +22,7 @@ const WebpackConfig = {
2222
{
2323
loader: 'ts-loader',
2424
options: {
25+
appendTsSuffixTo: [/\.vue$/],
2526
configFile: path.resolve(__dirname, './tsconfig.webpack.json'),
2627
},
2728
},
@@ -32,10 +33,15 @@ const WebpackConfig = {
3233
exclude: /node_modules/,
3334
use: ['babel-loader'],
3435
},
36+
{
37+
test: /\.(vue)/,
38+
exclude: /node_modules/,
39+
use: ['vue-loader'],
40+
},
3541
],
3642
},
3743
resolve: {
38-
extensions: ['.tsx', '.ts', '.js', '.jsx'],
44+
extensions: ['.tsx', '.ts', '.js', '.jsx', '.vue'],
3945
alias: {
4046
'vue-request': path.join(__dirname, '../src/index.ts'),
4147
},
@@ -44,6 +50,7 @@ const WebpackConfig = {
4450
new HtmlWebpackPlugin({
4551
template: path.resolve(__dirname, '../example/index.html'),
4652
}),
53+
new VueLoaderPlugin(),
4754
],
4855
devServer: {
4956
open: true,

‎package.json

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@typescript-eslint/eslint-plugin": "^4.8.2",
6868
"@typescript-eslint/parser": "^4.8.2",
6969
"@vue/babel-plugin-jsx": "^1.0.0-rc.3",
70+
"@vue/compiler-sfc": "^3.0.6",
7071
"@vue/test-utils": "^2.0.0-beta.8",
7172
"axios": "^0.21.1",
7273
"babel-jest": "^26.6.0",
@@ -96,6 +97,7 @@
9697
"ts-loader": "^8.0.11",
9798
"typescript": "^4.0.5",
9899
"vue": "^3.0.2",
100+
"vue-loader": "^16.1.2",
99101
"webpack": "^5.4.0",
100102
"webpack-cli": "^4.2.0",
101103
"webpack-dev-server": "^3.11.0"

0 commit comments

Comments
 (0)
Please sign in to comment.