Skip to content

Commit 0349072

Browse files
Hristo HristovHristo Hristov
authored andcommitted
feat(wc): replace rollup with vite config
1 parent ceba1ff commit 0349072

File tree

5 files changed

+110
-118
lines changed

5 files changed

+110
-118
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
@@ -33,7 +33,7 @@ jobs:
3333
- name: Update Router Navigation
3434
run: |
3535
find ./src -type f -name "*.ts" -exec sed -i "s|Router.go(\`/|Router.go(\`/${{ github.event.repository.name }}/|g" {} \;
36-
find ./ -type f -name "rollup.config.mjs" -exec sed -i "s|navigateFallback: '/index.html'|navigateFallback: 'index.html'|g" {} \;
36+
find ./ -type f -name "vite.config.ts" -exec sed -i "s|navigateFallback: '/index.html'|navigateFallback: 'index.html'|g" {} \;
3737
- run: npm run build
3838
- name: Update base href in index.html
3939
run: |

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

Lines changed: 7 additions & 11 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"
@@ -27,15 +27,10 @@
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": "^7.13.1",
3532
"@typescript-eslint/parser": "^7.13.1",
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",
4136
"concurrently": "^8.2.2",
@@ -44,12 +39,13 @@
4439
"eslint-plugin-lit": "^1.8.2",
4540
"igniteui-cli": "^13.1.5",
4641
"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",
5142
"source-map": "^0.7.4",
5243
"tslib": "^2.6.2",
53-
"@types/mocha": "^10.0.6"
44+
"@types/mocha": "^10.0.6",
45+
"vite": "^6.0.7",
46+
"vite-plugin-pwa": "^0.21.0",
47+
"vite-plugin-static-copy": "^2.1.0",
48+
"vite-plugin-babel": "^1.3.0",
49+
"vite-plugin-html": "^3.2.2"
5450
}
5551
}

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

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { defineConfig } from 'vite';
2+
import { createHtmlPlugin } from 'vite-plugin-html';
3+
import babel from 'vite-plugin-babel';
4+
import { VitePWA } from 'vite-plugin-pwa';
5+
import { viteStaticCopy } from 'vite-plugin-static-copy';
6+
7+
export default defineConfig({
8+
build: {
9+
rollupOptions: {
10+
output: {
11+
entryFileNames: '[hash].js',
12+
chunkFileNames: '[hash].js',
13+
assetFileNames: '[hash][extname]',
14+
},
15+
onwarn: (warning, warn) => {
16+
if (warning.code === 'THIS_IS_UNDEFINED') return;
17+
warn(warning);
18+
},
19+
},
20+
target: 'esnext',
21+
minify: 'terser',
22+
emptyOutDir: false,
23+
},
24+
plugins: [
25+
/** Copy static assets */
26+
viteStaticCopy({
27+
targets: [
28+
{ src: 'src/assets', dest: 'src' },
29+
],
30+
}),
31+
/** HTML Plugin with service worker injection */
32+
createHtmlPlugin({
33+
minify: true,
34+
inject: {
35+
data: {
36+
},
37+
},
38+
}),
39+
/** Babel Plugin for JS transpilation */
40+
babel({
41+
babelConfig: {
42+
presets: [
43+
[
44+
'@babel/preset-env',
45+
{
46+
targets: [
47+
'last 3 Chrome major versions',
48+
'last 3 Firefox major versions',
49+
'last 3 Edge major versions',
50+
'last 3 Safari major versions',
51+
],
52+
modules: false,
53+
bugfixes: true,
54+
},
55+
],
56+
],
57+
plugins: [
58+
[
59+
'babel-plugin-template-html-minifier',
60+
{
61+
modules: { lit: ['html', { name: 'css', encapsulation: 'style' }] },
62+
failOnError: false,
63+
strictCSS: true,
64+
htmlMinifier: {
65+
collapseWhitespace: true,
66+
conservativeCollapse: true,
67+
removeComments: true,
68+
caseSensitive: true,
69+
minifyCSS: true,
70+
},
71+
},
72+
],
73+
],
74+
},
75+
}),
76+
/** PWA Plugin for service worker generation */
77+
VitePWA({
78+
registerType: 'autoUpdate',
79+
strategies: 'generateSW',
80+
workbox: {
81+
globDirectory: 'dist',
82+
globPatterns: ['**/*.{html,js,css,webmanifest}'],
83+
globIgnores: ['polyfills/*.js', 'nomodule-*.js'],
84+
navigateFallback: '/index.html',
85+
runtimeCaching: [
86+
{
87+
urlPattern: /^polyfills\/.*\.js$/,
88+
handler: 'CacheFirst',
89+
},
90+
],
91+
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024
92+
},
93+
}),
94+
],
95+
});

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

Lines changed: 7 additions & 11 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"
@@ -35,15 +35,10 @@
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": "^7.13.1",
4340
"@typescript-eslint/parser": "^7.13.1",
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",
4944
"concurrently": "^8.2.2",
@@ -52,12 +47,13 @@
5247
"eslint-plugin-lit": "^1.8.2",
5348
"igniteui-cli": "^14.0.0",
5449
"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",
5950
"source-map": "^0.7.4",
6051
"tslib": "^2.6.2",
61-
"@types/mocha": "^10.0.6"
52+
"@types/mocha": "^10.0.6",
53+
"vite": "^6.0.7",
54+
"vite-plugin-pwa": "^0.21.0",
55+
"vite-plugin-static-copy": "^2.1.0",
56+
"vite-plugin-babel": "^1.3.0",
57+
"vite-plugin-html": "^3.2.2"
6258
}
6359
}

0 commit comments

Comments
 (0)