Skip to content

Commit

Permalink
chore: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 12, 2019
1 parent a030b61 commit 7351144
Show file tree
Hide file tree
Showing 6 changed files with 1,586 additions and 26 deletions.
2 changes: 2 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div id="app"></div>
<script src="/dist/bundle.js"></script>
4 changes: 4 additions & 0 deletions example/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import App from './source.vue'
import { createApp } from 'vue'

createApp().mount(App, '#app')
17 changes: 17 additions & 0 deletions example/source.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<button @click="inc">{{ count }}</button>
</template>

<script>
import { ref } from 'vue'
export default {
setup() {
const count = ref(0)
return {
count,
inc: () => { count.value++ }
}
}
}
</script>
37 changes: 37 additions & 0 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path')
const VueLoaderPlugin = require('../dist/plugin')

module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './main.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/dist/'
},
devServer: {
stats: "minimal",
contentBase: __dirname
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
resolve: {
alias: {
'vue': '@vue/runtime-dom'
}
},
resolveLoader: {
alias: {
'vue-loader': require.resolve('../')
}
},
plugins: [
new VueLoaderPlugin()
]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dist"
],
"scripts": {
"build": "tsc"
"build": "tsc",
"dev": "webpack-dev-server --config example/webpack.config.js --inline --hot"
},
"peerDependencies": {
"@vue/compiler-sfc": "^3.0.0-alpha.0"
Expand All @@ -23,6 +24,8 @@
"@types/loader-utils": "^1.1.3",
"@types/webpack": "^4.41.0",
"typescript": "^3.7.3",
"webpack": "^4.41.2"
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
}
}
Loading

0 comments on commit 7351144

Please # to comment.