Skip to content

Commit 7351144

Browse files
committed
chore: add example
1 parent a030b61 commit 7351144

File tree

6 files changed

+1586
-26
lines changed

6 files changed

+1586
-26
lines changed

Diff for: example/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="app"></div>
2+
<script src="/dist/bundle.js"></script>

Diff for: example/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import App from './source.vue'
2+
import { createApp } from 'vue'
3+
4+
createApp().mount(App, '#app')

Diff for: example/source.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<button @click="inc">{{ count }}</button>
3+
</template>
4+
5+
<script>
6+
import { ref } from 'vue'
7+
8+
export default {
9+
setup() {
10+
const count = ref(0)
11+
return {
12+
count,
13+
inc: () => { count.value++ }
14+
}
15+
}
16+
}
17+
</script>

Diff for: example/webpack.config.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const path = require('path')
2+
const VueLoaderPlugin = require('../dist/plugin')
3+
4+
module.exports = {
5+
mode: 'development',
6+
entry: path.resolve(__dirname, './main.js'),
7+
output: {
8+
path: path.resolve(__dirname, 'dist'),
9+
filename: 'bundle.js',
10+
publicPath: '/dist/'
11+
},
12+
devServer: {
13+
stats: "minimal",
14+
contentBase: __dirname
15+
},
16+
module: {
17+
rules: [
18+
{
19+
test: /\.vue$/,
20+
loader: 'vue-loader'
21+
}
22+
]
23+
},
24+
resolve: {
25+
alias: {
26+
'vue': '@vue/runtime-dom'
27+
}
28+
},
29+
resolveLoader: {
30+
alias: {
31+
'vue-loader': require.resolve('../')
32+
}
33+
},
34+
plugins: [
35+
new VueLoaderPlugin()
36+
]
37+
}

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"dist"
1010
],
1111
"scripts": {
12-
"build": "tsc"
12+
"build": "tsc",
13+
"dev": "webpack-dev-server --config example/webpack.config.js --inline --hot"
1314
},
1415
"peerDependencies": {
1516
"@vue/compiler-sfc": "^3.0.0-alpha.0"
@@ -23,6 +24,8 @@
2324
"@types/loader-utils": "^1.1.3",
2425
"@types/webpack": "^4.41.0",
2526
"typescript": "^3.7.3",
26-
"webpack": "^4.41.2"
27+
"webpack": "^4.41.2",
28+
"webpack-cli": "^3.3.10",
29+
"webpack-dev-server": "^3.9.0"
2730
}
2831
}

0 commit comments

Comments
 (0)