Skip to content

Commit 65f754c

Browse files
committed
feat: add vue3 dependencies
1 parent 3a4ff48 commit 65f754c

File tree

8 files changed

+92
-9
lines changed

8 files changed

+92
-9
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const PORT = 8081
1111
module.exports = {
1212
mode: NODE_ENV,
1313
entry: {
14-
main: process.env.NODE_ENV === 'development' ? path.resolve(__dirname, '../example/index.js') : path.resolve(__dirname, '../src/index.js'),
14+
main: process.env.NODE_ENV === 'development' ? path.resolve(__dirname, '../example/vue2.js') : path.resolve(__dirname, '../src/index.js'),
1515
},
1616
output: {
1717
path: path.resolve(__dirname, '../package'),

build/webpack.configvue3.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const VueLoaderPlugin = require('vue-loader/dist/plugin').default;
2+
const path = require('path')
3+
const HtmlWebpackPlugin = require('html-webpack-plugin')
4+
5+
const NODE_ENV = process.env.NODE_ENV
6+
7+
8+
const HOST = 'localhost'
9+
const PORT = 8081
10+
11+
module.exports = {
12+
mode: NODE_ENV,
13+
entry: {
14+
main: process.env.NODE_ENV === 'development' ? path.resolve(__dirname, '../example/vue3.js') : path.resolve(__dirname, '../src/index.js'),
15+
},
16+
output: {
17+
path: path.resolve(__dirname, '../package'),
18+
filename: 'vue-luck-draw.js', //打包之后生成的文件名,可以随意写。
19+
library: 'vue-luck-draw', // 指定类库名,主要用于直接引用的方式(比如使用script 标签)
20+
libraryExport: "default", // 对外暴露default属性,就可以直接调用default里的属性
21+
globalObject: 'this', // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
22+
libraryTarget: 'umd' // 定义打包方式Universal Module Definition,同时支持在CommonJS、AMD和全局变量使用
23+
},
24+
module: {
25+
rules: [
26+
{ test: /\.vue$/,
27+
use: 'vue-loader'
28+
},
29+
{
30+
test: /\.(png|svg|jpg|gif)$/,
31+
use: [
32+
'file-loader'
33+
]
34+
}
35+
],
36+
},
37+
devServer: {
38+
clientLogLevel: 'warning',
39+
hot: true,
40+
contentBase: 'dist',
41+
compress: true,
42+
host: HOST,
43+
port: PORT,
44+
open: true,
45+
overlay: { warnings: false, errors: true },
46+
publicPath: '/',
47+
contentBase: path.join(__dirname, 'dist'),
48+
quiet: true
49+
},
50+
plugins: [
51+
new VueLoaderPlugin(),
52+
new HtmlWebpackPlugin({
53+
template: './example/index.html',
54+
filename: 'index.html',
55+
inject: true
56+
}),
57+
]
58+
}

example/index.js renamed to example/vue2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue';
22
import App from './index.vue';
3-
import LuckDraw from '../src/index.js';
3+
import LuckDraw from '../src/vue2.js';
44

55
Vue.use(LuckDraw)
66

example/vue3.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createApp } from 'vue';
2+
import App from './index.vue';
3+
import LuckDraw from '../src/vue3.js';
4+
5+
const app = createApp(App);
6+
7+
app.use(LuckDraw).mount('#app');

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,28 @@
1818
"package.json",
1919
"dist",
2020
"vue3",
21-
"index.js"
21+
"index.js",
22+
"package"
2223
],
2324
"scripts": {
2425
"build": "cross-env NODE_ENV=production webpack --config=build/webpack.config.js",
25-
"start": "cross-env NODE_ENV=development webpack serve --config=build/webpack.config.js"
26+
"start": "cross-env NODE_ENV=development webpack serve --config=build/webpack.configvue2.js",
27+
"start:vue3": "cross-env NODE_ENV=development webpack serve --config=build/webpack.configvue3.js"
2628
},
2729
"homepage": "https://100px.net",
2830
"dependencies": {
29-
"clean-webpack-plugin": "^3.0.0",
30-
"lucky-canvas": "^1.5.3",
31-
"vue": "^2.6.12"
31+
"@vue/compiler-sfc": "^3.0.7",
32+
"lucky-canvas": "^1.5.3"
3233
},
3334
"devDependencies": {
35+
"clean-webpack-plugin": "^3.0.0",
3436
"copy-webpack-plugin": "^8.0.0",
3537
"cross-env": "^7.0.3",
3638
"file-loader": "^6.2.0",
3739
"html-webpack-plugin": "^5.3.1",
3840
"mini-css-extract-plugin": "^1.3.9",
39-
"vue-loader": "^15.9.6",
40-
"vue-template-compiler": "^2.6.12",
41+
"vue": "^3.0.7",
42+
"vue-loader": "^16.1.2",
4143
"webpack": "^5.27.1",
4244
"webpack-cli": "^4.5.0",
4345
"webpack-dev-server": "^3.11.2"
File renamed without changes.

src/vue3.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import LuckDraw from './LuckDraw.vue'
2+
import LuckyGrid from './LuckyGrid.vue'
3+
import LuckyWheel from './LuckyWheel.vue'
4+
5+
const install = (Vue, options) => {
6+
Vue.component('LuckDraw', LuckDraw)
7+
Vue.component('LuckyGrid', LuckyGrid)
8+
Vue.component('LuckyWheel', LuckyWheel)
9+
}
10+
11+
if (typeof window !== 'undefined' && window.Vue) {
12+
install(window.Vue)
13+
}
14+
15+
export default { install }
16+
export { LuckyGrid, LuckyWheel }

vue-luck-draw-3.4.5.tgz

11.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)