Skip to content

Commit

Permalink
fix: update vite + vue2 compiler dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Jevon617 committed May 6, 2023
1 parent f32e57a commit d7d873b
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 77 deletions.
1 change: 0 additions & 1 deletion examples/react-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "react",
"type": "module",
"private": true,
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
Expand Down
12 changes: 12 additions & 0 deletions examples/vue2-vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="app"></div>
<script type="module" src="./src/main.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions examples/vue2-vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "vue2-vite",
"version": "1.0.0",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@vitejs/plugin-vue2": "^2.2.0",
"@vue/compiler-sfc": "^2.7.0",
"unplugin-svg-component": "workspace:*",
"vite": "^3.2.3",
"vue": "^2.7.14"

}
}
34 changes: 34 additions & 0 deletions examples/vue2-vite/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script>
export default {
name: 'App',
data() {
return {
}
},
methods: {
handleClick() {
console.log('click')
},
},
}
</script>

<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<MySvgIcon name="vue" class="test" @click="handleClick" />
<MySvgIcon name="icon-card2" @click="handleClick" />
<MySvgIcon name="icon-barCode" @click="handleClick" />
</div>
</template>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Binary file added examples/vue2-vite/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/vue2-vite/src/icons/icon-addUser.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/vue2-vite/src/icons/icon-barCode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/vue2-vite/src/icons/icon-card2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/vue2-vite/src/icons/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions examples/vue2-vite/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Vue from 'vue'
import App from './App.vue'
import MySvgIcon from '~virtual/svg-component'

Vue.config.productionTip = false

const app = new Vue({
render: h => h(App),
})

Vue.component(MySvgIcon.name, MySvgIcon)

app.$mount('#app')
16 changes: 16 additions & 0 deletions examples/vue2-vite/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import UnpluginSvgComponent from 'unplugin-svg-component/vite'
import vitePluginVue2 from '@vitejs/plugin-vue2'

export default defineConfig({
plugins: [
vitePluginVue2(),
UnpluginSvgComponent({
iconDir: path.resolve(__dirname, './src/icons'),
vueVersion: 'auto',
componentName: 'MySvgIcon',
preserveColor: /vue\.svg$/,
}),
],
})
6 changes: 2 additions & 4 deletions examples/vue2-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "webpack-demo",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build"
Expand All @@ -13,8 +12,7 @@
"@babel/core": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"unplugin-svg-component": "workspace:*",
"vue-template-compiler": "^2.7.13",
"vue-template-es2015-compiler": "^1.9.0"
"@vue/compiler-sfc": "^2.7.0",
"unplugin-svg-component": "workspace:*"
}
}
11 changes: 8 additions & 3 deletions examples/vue2-webpack/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ export default {
return {
}
},
methods: {
handleClick() {
console.log('click')
},
},
}
</script>

<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<MySvgIcon name="vue" />
<MySvgIcon name="icon-card2" />
<MySvgIcon name="icon-barCode" />
<MySvgIcon name="vue" class="test" @click="handleClick" />
<MySvgIcon name="icon-card2" @click="handleClick" />
<MySvgIcon name="icon-barCode" @click="handleClick" />
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion examples/vue2-webpack/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const path = require('node:path')
const { defineConfig } = require('@vue/cli-service')
const UnpluginSvgComponent = require('unplugin-svg-component/webpack').default

Expand Down
3 changes: 1 addition & 2 deletions examples/vue3-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "vite-demo",
"private": true,
"name": "vue3-vite",
"scripts": {
"dev": "vite",
"build": "vite build"
Expand Down
15 changes: 1 addition & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,7 @@
"test": "vitest"
},
"peerDependencies": {
"@vue/compiler-sfc": "^3.2.40",
"vue-template-compiler": "^2.6.12",
"vue-template-es2015-compiler": "^1.9.0"
},
"peerDependenciesMeta": {
"@vue/compiler-sfc": {
"optional": true
},
"vue-template-compiler": {
"optional": true
},
"vue-template-es2015-compiler": {
"optional": true
}
"@vue/compiler-sfc": ">=2.7.0 <=3.2.47"
},
"dependencies": {
"cors": "^2.8.5",
Expand Down
Loading

0 comments on commit d7d873b

Please sign in to comment.