Skip to content

Commit 024ee5f

Browse files
authored
feat: replace rollup with vite configuration for wc (#1364)
1 parent 1af70f5 commit 024ee5f

File tree

6 files changed

+72
-131
lines changed

6 files changed

+72
-131
lines changed

packages/cli/templates/webcomponents/igc-ts/projects/_base/files/__dot__github/workflows/github-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Update Router Navigation
3535
run: |
3636
find ./src -type f -name "*.ts" -exec sed -i "s|Router.go(\`/|Router.go(\`/${{ github.event.repository.name }}/|g" {} \;
37-
find ./ -type f -name "rollup.config.mjs" -exec sed -i "s|navigateFallback: '/index.html'|navigateFallback: 'index.html'|g" {} \;
37+
find ./ -type f -name "vite.config.ts" -exec sed -i "s|navigateFallback: '/index.html'|navigateFallback: 'index.html'|g" {} \;
3838
- run: npm run build
3939
- name: Update base href in index.html
4040
run: |

packages/cli/templates/webcomponents/igc-ts/projects/_base/files/package.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,36 @@
1414
},
1515
"scripts": {
1616
"start": "tsc && concurrently -k -r \"tsc --watch\" \"wds\"",
17-
"build": "rimraf dist && tsc && node --max-old-space-size=4096 node_modules/rollup/dist/bin/rollup -c rollup.config.mjs",
17+
"build": "rimraf dist && tsc && node --max-old-space-size=4096 node_modules/vite/bin/vite.js build",
1818
"start:build": "web-dev-server --root-dir dist --app-index index.html --open",
1919
"lint": "eslint \"**/*.{js,ts}\" --ignore-path .gitignore",
2020
"test": "tsc --project tsconfig.test.json && wtr"
2121
},
2222
"dependencies": {
2323
"@vaadin/router": "^1.7.4",
24-
"lit": "^3.1.2",
25-
"typescript": "~5.5.4",
24+
"lit": "^3.2.1",
25+
"typescript": "~5.7.2",
2626
"igniteui-webcomponents": "~5.1.0"
2727
},
2828
"devDependencies": {
2929
"@babel/preset-env": "^7.20.2",
30-
"@open-wc/building-rollup": "^2.2.1",
3130
"@open-wc/testing": "^4.0.0",
32-
"@rollup/plugin-babel": "^6.0.3",
33-
"@rollup/plugin-node-resolve": "^15.0.1",
3431
"@typescript-eslint/eslint-plugin": "^8.21.0",
3532
"@typescript-eslint/parser": "^8.21.0",
3633
"@web/dev-server": "^0.4.6",
37-
"@web/rollup-plugin-html": "^2.3.0",
38-
"@web/rollup-plugin-import-meta-assets": "^1.0.7",
3934
"@web/test-runner": "^0.18.0",
4035
"babel-plugin-template-html-minifier": "^4.1.0",
41-
"concurrently": "^8.2.2",
36+
"concurrently": "^9.1.2",
4237
"deepmerge": "^4.2.2",
4338
"eslint": "^8.57.0",
4439
"eslint-plugin-lit": "^1.8.2",
4540
"igniteui-cli": "^13.1.5",
46-
"rimraf": "^5.0.5",
47-
"rollup": "^2.79.0",
48-
"rollup-plugin-copy-assets": "^2.0.3",
49-
"rollup-plugin-terser": "^7.0.2",
50-
"rollup-plugin-workbox": "^8.1.0",
41+
"rimraf": "^5.0.10",
5142
"source-map": "^0.7.4",
52-
"tslib": "^2.6.2",
53-
"@types/mocha": "^10.0.6"
43+
"tslib": "^2.8.1",
44+
"@types/mocha": "^10.0.6",
45+
"vite": "^6.0.10",
46+
"vite-plugin-pwa": "^0.21.1",
47+
"vite-plugin-static-copy": "^2.2.0"
5448
}
5549
}

packages/cli/templates/webcomponents/igc-ts/projects/_base/files/rollup.config.mjs

Lines changed: 0 additions & 95 deletions
This file was deleted.

packages/cli/templates/webcomponents/igc-ts/projects/_base/files/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"compilerOptions": {
3-
"target": "es2018",
4-
"module": "esnext",
3+
"target": "es2021",
4+
"module": "es2022",
55
"moduleResolution": "node",
66
"noEmitOnError": true,
77
"lib": [
8-
"es2017",
8+
"es2021",
99
"dom",
1010
"dom.iterable"
1111
],
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { defineConfig } from 'vite';
2+
import { VitePWA } from 'vite-plugin-pwa';
3+
import { viteStaticCopy } from 'vite-plugin-static-copy';
4+
5+
export default defineConfig({
6+
build: {
7+
rollupOptions: {
8+
output: {
9+
entryFileNames: '[hash].js',
10+
chunkFileNames: '[hash].js',
11+
assetFileNames: '[hash][extname]',
12+
},
13+
onwarn: (warning, warn) => {
14+
if (warning.code === 'THIS_IS_UNDEFINED') return;
15+
warn(warning);
16+
},
17+
},
18+
target: 'es2021',
19+
minify: 'terser',
20+
emptyOutDir: false,
21+
},
22+
plugins: [
23+
/** Copy static assets */
24+
viteStaticCopy({
25+
targets: [
26+
{ src: 'src/assets', dest: 'src' },
27+
],
28+
}),
29+
/** PWA Plugin for service worker generation */
30+
VitePWA({
31+
registerType: 'autoUpdate',
32+
strategies: 'generateSW',
33+
workbox: {
34+
globDirectory: 'dist',
35+
globPatterns: ['**/*.{html,js,css,webmanifest}'],
36+
globIgnores: ['polyfills/*.js', 'nomodule-*.js'],
37+
navigateFallback: '/index.html',
38+
runtimeCaching: [
39+
{
40+
urlPattern: /^polyfills\/.*\.js$/,
41+
handler: 'CacheFirst',
42+
},
43+
],
44+
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024
45+
},
46+
}),
47+
],
48+
});

packages/cli/templates/webcomponents/igc-ts/projects/_base_with_home/files/package.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"scripts": {
1616
"start": "tsc && concurrently -k -r \"tsc --watch\" \"wds\"",
17-
"build": "rimraf dist && tsc && node --max-old-space-size=4096 node_modules/rollup/dist/bin/rollup -c rollup.config.mjs",
17+
"build": "rimraf dist && tsc && node --max-old-space-size=4096 node_modules/vite/bin/vite.js build",
1818
"start:build": "web-dev-server --root-dir dist --app-index index.html --open",
1919
"lint": "eslint \"**/*.{js,ts}\" --ignore-path .gitignore",
2020
"test": "tsc --project tsconfig.test.json && wtr"
@@ -30,34 +30,28 @@
3030
"igniteui-webcomponents-grids": "~5.0.0",
3131
"igniteui-webcomponents-inputs": "~5.0.0",
3232
"igniteui-webcomponents-layouts": "~5.0.0",
33-
"lit": "^3.1.2",
34-
"typescript": "~5.5.4"
33+
"lit": "^3.2.1",
34+
"typescript": "~5.7.2"
3535
},
3636
"devDependencies": {
3737
"@babel/preset-env": "^7.20.2",
38-
"@open-wc/building-rollup": "^2.2.1",
3938
"@open-wc/testing": "^4.0.0",
40-
"@rollup/plugin-babel": "^6.0.3",
41-
"@rollup/plugin-node-resolve": "^15.0.1",
4239
"@typescript-eslint/eslint-plugin": "^8.21.0",
4340
"@typescript-eslint/parser": "^8.21.0",
4441
"@web/dev-server": "^0.4.6",
45-
"@web/rollup-plugin-html": "^2.3.0",
46-
"@web/rollup-plugin-import-meta-assets": "^1.0.7",
4742
"@web/test-runner": "^0.18.0",
4843
"babel-plugin-template-html-minifier": "^4.1.0",
49-
"concurrently": "^8.2.2",
44+
"concurrently": "^9.1.2",
5045
"deepmerge": "^4.2.2",
5146
"eslint": "^8.57.0",
5247
"eslint-plugin-lit": "^1.8.2",
5348
"igniteui-cli": "^14.0.0",
54-
"rimraf": "^5.0.5",
55-
"rollup": "^2.79.0",
56-
"rollup-plugin-copy-assets": "^2.0.3",
57-
"rollup-plugin-terser": "^7.0.2",
58-
"rollup-plugin-workbox": "^8.1.0",
49+
"rimraf": "^5.0.10",
5950
"source-map": "^0.7.4",
60-
"tslib": "^2.6.2",
61-
"@types/mocha": "^10.0.6"
51+
"tslib": "^2.8.1",
52+
"@types/mocha": "^10.0.6",
53+
"vite": "^6.0.10",
54+
"vite-plugin-pwa": "^0.21.1",
55+
"vite-plugin-static-copy": "^2.2.0"
6256
}
6357
}

0 commit comments

Comments
 (0)