Skip to content

Commit 8a57a23

Browse files
authored
refactor: upgrade Vue version and switch to Vite (#84)
* refactor: upgrade Vue version from v2 to v3 and switch to Vite
1 parent 6b94b96 commit 8a57a23

12 files changed

+2390
-20640
lines changed

.eslintrc.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
module.exports = {
22
extends: [
33
"eslint:recommended",
4-
// "plugin:vue/vue3-recommended",
5-
"plugin:vue/recommended" // Use this if you are using Vue.js 2.x.
4+
"plugin:vue/vue3-recommended",
65
],
76
env: {
87
"node": true,
98
},
10-
parser: "@babel/eslint-parser",
119
};

README.md

+19-30
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ This project was bootstrapped with [Vue CLI](https://cli.vuejs.org/)
2222
npm install
2323
```
2424

25-
1. Start a local server and run the application. (The running application can be found here: http://localhost:8080)
25+
1. Start a local server and run the application. (The running application can be found here: http://localhost:5173)
2626
```sh
27-
npm run serve
27+
npm run dev
2828
```
2929

3030

@@ -49,40 +49,29 @@ Then, you can use the custom element in an HTML page:
4949

5050
Currently Chrome, Safari, Firefox and Edge (Chromium-based) support Web Components natively.
5151

52-
5352
## Configure Vue to work with Web Components defined outside of it
54-
To use Web Components in Vue Application a configuration option should be provided in the `main.js` file to tell the Vue about these components. More can be found in the documentation of [Vue.config.ignoredElements](https://vuejs.org/v2/api/#ignoredElements):
5553

56-
**main.js**
57-
```js
58-
Vue.config.ignoredElements = [/^ui5-/];
59-
```
54+
It is recommended to exclude our custom elements from component resolution by specifying `compilerOptions.isCustomElement` in our `vite.config` file.
6055

56+
```ts
57+
// vite.config.js
6158
62-
## Configure Vue Build
63-
When UI5 Web Components are used they include all of their translation files and CLDR data files in the application bundle.
64-
In order to decrease the bundle size of the application a custom Webpack configuration should be provided.
59+
import { defineConfig } from 'vite'
60+
import vue from '@vitejs/plugin-vue'
6561
66-
Create `vue.config.js` file:
67-
68-
**vue.config.js**
69-
```js
70-
module.exports = {
71-
configureWebpack: {
72-
module: {
73-
rules: [
74-
{
75-
test: [/cldr\/.*\.json$/, /i18n\/.*\.json$/],
76-
loader: 'file-loader',
77-
options: {
78-
name: 'static/media/[name].[hash:8].[ext]',
79-
},
80-
type: 'javascript/auto'
62+
// https://vitejs.dev/config/
63+
export default defineConfig({
64+
plugins: [
65+
vue({
66+
template: {
67+
compilerOptions: {
68+
// treat all tags with a "ui5-" prefix as custom elements
69+
isCustomElement: tag => tag.startsWith('ui5-')
8170
}
82-
]
83-
}
84-
}
85-
};
71+
}
72+
})
73+
]
74+
})
8675
```
8776
8877
### Where is the npm package?

babel.config.js

-5
This file was deleted.

public/index.html renamed to index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
87
<title>UI5 Web Components Vue Sample Application</title>
98
</head>
109
<body>
1110
<noscript>
1211
<strong>We're sorry but ui5-webcomponents-sample-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
1312
</noscript>
14-
<div id="app"></div>
13+
<div id="app" style="height: 100%;"></div>
14+
<script type="module" src="/src/main.js"></script>
1515
<!-- built files will be auto injected -->
1616
</body>
1717
</html>

0 commit comments

Comments
 (0)