Skip to content

Commit

Permalink
chore(build): migrate build system from rollup and parcel to vite
Browse files Browse the repository at this point in the history
Replaces Rollup and Parcel with Vite as the sole build tool in order to reduce complexity. The
changes involve:

- Removed `.parcelrc` and `rollup.config.js`, as their functionalities are now handled by Vite.
- Introduced multiple Vite config to support the various build outputs previously managed by Rollup.
- Updated `package.json` to integrate Vite dependencies and remove those related to Rollup and
  Parcel (2 Rollup plugins have been retained, including Babel to enhance browser compatibility and
  Terser for minifying the UMD build).
- Modified `scss/pillarbox.scss` to enhance compatibility with the new Vite build setup. This update
  includes simplifying SCSS imports, making it easier to resolve external dependencies without
  depending on the file's location.
- The server previously started by Parcel for the demo pages is now efficiently handled by Vite's
  native development server.
  • Loading branch information
jboix committed Oct 23, 2024
1 parent f69e638 commit eae3b82
Show file tree
Hide file tree
Showing 15 changed files with 9,024 additions and 14,368 deletions.
8 changes: 0 additions & 8 deletions .parcelrc

This file was deleted.

22,970 changes: 8,885 additions & 14,085 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 9 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,22 @@
"directories": {
"doc": "docs"
},
"targets": {
"main": false,
"github-page": {
"publicUrl": "./",
"isLibrary": false,
"outputFormat": "esmodule"
}
},
"scripts": {
"build": "npm run build:lib && npm run build:typings && npm run build:css",
"build:css": "sass ./scss/pillarbox.scss:dist/pillarbox.min.css --style compressed --source-map --load-path node_modules",
"build:lib": "rollup -c",
"build:lib": "npm run build:core && npm run build:es && npm run build:cjs && npm run build:umd",
"build:core": "vite build --config vite.config.core.js",
"build:es": "vite build --config vite.config.es.js",
"build:cjs": "vite build --config vite.config.cjs.js",
"build:umd": "vite build --config vite.config.umd.js",
"build:typings": "npx -p typescript tsc",
"eslint": "eslint --ext .js src",
"generate:docs": "jsdoc --configure docs/api/jsdoc.json --verbose",
"github:page": "parcel build index.html --target github-page && npm run generate:docs",
"github:page": "vite build && npm run generate:docs",
"outdated": "npm outdated",
"prebuild": "rimraf dist",
"release:ci": "semantic-release",
"start": "parcel -p 6969 index.html",
"start": "vite --port 6969 --open",
"stylelint": "stylelint **/*.scss --custom-syntax --allow-empty-input",
"stylelint:fix": "stylelint **/*.scss --fix",
"test": "jest --verbose",
Expand All @@ -69,11 +65,7 @@
"@babel/preset-env": "^7.24.1",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@parcel/transformer-sass": "^2.11.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
Expand All @@ -91,16 +83,14 @@
"jest-environment-jsdom": "^29.6.1",
"jsdoc": "^4.0.2",
"jsdoc-tsimport-plugin": "^1.0.5",
"parcel": "^2.11.0",
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"rollup-plugin-filesize": "^10.0.0",
"sass": "^1.70.0",
"semantic-release": "^23.0.0",
"stylelint": "^16.2.1",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-order": "^6.0.4",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vite": "^5.4.10"
},
"dependencies": {
"video.js": "^8.11.8",
Expand Down
246 changes: 0 additions & 246 deletions rollup.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion scss/pillarbox.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../node_modules/video.js/dist/video-js';
@import 'video.js/dist/video-js';

/*
******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/lang/de.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Pillarbox from '../pillarbox.js';
import * as vjsLang from 'video.js/dist/lang/de.json';
import * as pillarboxLang from './de.json';
import vjsLang from 'video.js/dist/lang/de.json';
import pillarboxLang from './de.json';

Pillarbox.addLanguage('de', {
...vjsLang,
Expand Down
4 changes: 2 additions & 2 deletions src/lang/en.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Pillarbox from '../pillarbox.js';
import * as vjsLang from 'video.js/dist/lang/en.json';
import * as pillarboxLang from './en.json';
import vjsLang from 'video.js/dist/lang/en.json';
import pillarboxLang from './en.json';

Pillarbox.addLanguage('en', {
...vjsLang,
Expand Down
4 changes: 2 additions & 2 deletions src/lang/fr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Pillarbox from '../pillarbox.js';
import * as vjsLang from 'video.js/dist/lang/fr.json';
import * as pillarboxLang from './fr.json';
import vjsLang from 'video.js/dist/lang/fr.json';
import pillarboxLang from './fr.json';

Pillarbox.addLanguage('fr', {
...vjsLang,
Expand Down
4 changes: 2 additions & 2 deletions src/lang/it.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Pillarbox from '../pillarbox.js';
import * as vjsLang from 'video.js/dist/lang/it.json';
import * as pillarboxLang from './it.json';
import vjsLang from 'video.js/dist/lang/it.json';
import pillarboxLang from './it.json';

Pillarbox.addLanguage('it', {
...vjsLang,
Expand Down
2 changes: 1 addition & 1 deletion src/lang/rm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Pillarbox from '../pillarbox.js';
import * as pillarboxLang from './rm.json';
import pillarboxLang from './rm.json';

Pillarbox.addLanguage('rm', {
...pillarboxLang,
Expand Down
25 changes: 25 additions & 0 deletions vite.config.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from 'vite';
import babel from '@rollup/plugin-babel';

export default defineConfig({
esbuild: false,
build: {
sourcemap: true,
emptyOutDir: false,
lib: {
formats: ['cjs'],
name: 'pillarbox',
entry: './build.umd.js'
},
rollupOptions: {
external: ['video.js', 'videojs-contrib-eme'],
output: {
entryFileNames: 'pillarbox.cjs.js'
},
plugins: [babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**'
})]
}
}
});
Loading

0 comments on commit eae3b82

Please sign in to comment.