Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: bundle with vite #6068

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ composer.phar

build/
js/
/css
node_modules/
src/fonts
*.clover
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion lib/Listener/CalendarReferenceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CalendarReferenceListener implements IEventListener {

/** @var IConfig */
private $config;

/** @var CompareVersion */
private $compareVersion;

Expand Down Expand Up @@ -109,5 +109,6 @@ public function handle(Event $event): void {
$this->initialStateService->provideInitialState('publicCalendars', $publicCalendars);

Util::addScript(Application::APP_ID, 'calendar-reference');
Util::addStyle(Application::APP_ID, 'calendar-style');
}
}
5,504 changes: 2,493 additions & 3,011 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"homepage": "https://github.com/nextcloud/calendar",
"license": "agpl",
"private": true,
"type": "module",
"scripts": {
"build": "webpack --node-env production --progress",
"dev": "webpack --node-env development --progress",
"watch": "webpack --node-env development --progress --watch",
"build": "vite build --mode=production",
"dev": "vite build --mode=development",
"watch": "vite build --mode=development --watch",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint src css",
"stylelint:fix": "stylelint src css --fix",
"stylelint": "stylelint src",
"stylelint:fix": "stylelint src --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
Expand Down Expand Up @@ -62,7 +63,6 @@
"autosize": "^6.0.1",
"color-convert": "^2.0.1",
"color-string": "^1.9.1",
"core-js": "^3.37.1",
"css-color-names": "^1.0.1",
"debounce": "^2.1.0",
"jstz": "^2.1.1",
Expand Down Expand Up @@ -90,21 +90,18 @@
"npm": "^10.0.0"
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@nextcloud/babel-config": "^1.0.0",
"@nextcloud/browserslist-config": "^3.0.1",
"@nextcloud/eslint-config": "^8.3.0",
"@nextcloud/stylelint-config": "^2.4.0",
"@nextcloud/webpack-vue-config": "^6.0.1",
"@nextcloud/vite-config": "^1.2.5",
"@vue/test-utils": "^2.4.5",
"@vue/vue2-jest": "^29.2.6",
"babel-jest": "^29.7.0",
"babel-loader-exclude-node-modules-except": "^1.2.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-serializer-vue": "^3.1.0",
"resolve-url-loader": "^5.0.0",
"vite": "^5.3.1",
"vue-template-compiler": "^2.7.16"
},
"optionalDependencies": {
Expand Down
16 changes: 3 additions & 13 deletions src/appointments/main-booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getRequestToken } from '@nextcloud/auth'
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
import 'vite/modulepreload-polyfill'

import { loadState } from '@nextcloud/initial-state'
import { linkTo } from '@nextcloud/router'
import { translate, translatePlural } from '@nextcloud/l10n'
import Vue from 'vue'

import Booking from '../views/Appointments/Booking.vue'

// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(getRequestToken())

// Correct the root of the app for chunk loading
// OC.linkTo matches the apps folders
// OC.generateUrl ensure the index.php (or not)
// We do not want the index.php since we're loading files
// eslint-disable-next-line
__webpack_public_path__ = linkTo('calendar', 'js/')

Vue.prototype.$t = translate
Vue.prototype.$n = translatePlural

Expand Down
16 changes: 3 additions & 13 deletions src/appointments/main-confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getRequestToken } from '@nextcloud/auth'
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
import 'vite/modulepreload-polyfill'

import { loadState } from '@nextcloud/initial-state'
import { linkTo } from '@nextcloud/router'
import { translate, translatePlural } from '@nextcloud/l10n'
import Vue from 'vue'

import Confirmation from '../views/Appointments/Confirmation.vue'

// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(getRequestToken())

// Correct the root of the app for chunk loading
// OC.linkTo matches the apps folders
// OC.generateUrl ensure the index.php (or not)
// We do not want the index.php since we're loading files
// eslint-disable-next-line
__webpack_public_path__ = linkTo('calendar', 'js/')

Vue.prototype.$t = translate
Vue.prototype.$n = translatePlural

Expand Down
16 changes: 3 additions & 13 deletions src/appointments/main-conflict.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getRequestToken } from '@nextcloud/auth'
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
import 'vite/modulepreload-polyfill'

import { loadState } from '@nextcloud/initial-state'
import { linkTo } from '@nextcloud/router'
import { translate, translatePlural } from '@nextcloud/l10n'
import Vue from 'vue'

import Conflict from '../views/Appointments/Conflict.vue'

// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(getRequestToken())

// Correct the root of the app for chunk loading
// OC.linkTo matches the apps folders
// OC.generateUrl ensure the index.php (or not)
// We do not want the index.php since we're loading files
// eslint-disable-next-line
__webpack_public_path__ = linkTo('calendar', 'js/')

Vue.prototype.$t = translate
Vue.prototype.$n = translatePlural

Expand Down
16 changes: 3 additions & 13 deletions src/appointments/main-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getRequestToken } from '@nextcloud/auth'
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
import 'vite/modulepreload-polyfill'

import { loadState } from '@nextcloud/initial-state'
import { linkTo } from '@nextcloud/router'
import Vue from 'vue'
import { translate, translatePlural } from '@nextcloud/l10n'

import Overview from '../views/Appointments/Overview.vue'

// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(getRequestToken())

// Correct the root of the app for chunk loading
// OC.linkTo matches the apps folders
// OC.generateUrl ensure the index.php (or not)
// We do not want the index.php since we're loading files
// eslint-disable-next-line
__webpack_public_path__ = linkTo('calendar', 'js/')

const configs = loadState('calendar', 'appointmentConfigs')
const userInfo = loadState('calendar', 'userInfo')

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 4 additions & 15 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import 'core-js/stable/index.js'

import '../css/calendar.scss'
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
import 'vite/modulepreload-polyfill'

import './css/calendar.scss'

import Vue from 'vue'
import App from './App.vue'
import router from './router.js'
import store from './store/index.js'
import { sync } from 'vuex-router-sync'
import { getRequestToken } from '@nextcloud/auth'
import { linkTo } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
import { translate, translatePlural } from '@nextcloud/l10n'
import AppointmentConfig from './models/appointmentConfig.js'
Expand All @@ -31,17 +31,6 @@ Vue.directive('ClickOutside', ClickOutside)
Vue.use(VTooltip)
Vue.use(VueShortKey, { prevent: ['input', 'textarea'] })

// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(getRequestToken())

// Correct the root of the app for chunk loading
// OC.linkTo matches the apps folders
// OC.generateUrl ensure the index.php (or not)
// We do not want the index.php since we're loading files
// eslint-disable-next-line
__webpack_public_path__ = linkTo('calendar', 'js/')

sync(store, router)

Vue.prototype.$t = translate
Expand Down
11 changes: 5 additions & 6 deletions src/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

// eslint-disable-next-line import/no-unresolved, n/no-missing-import
import 'vite/modulepreload-polyfill'

import { registerWidget, NcCustomPickerRenderResult } from '@nextcloud/vue/dist/Functions/registerReference.js'
import { linkTo } from '@nextcloud/router'
import { getRequestToken } from '@nextcloud/auth'
import { translate, translatePlural } from '@nextcloud/l10n'
import '../css/calendar.scss'

__webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line
__webpack_public_path__ = linkTo('calendar', 'js/') // eslint-disable-line
import './css/calendar.scss'

registerWidget('calendar_widget', async (el, { richObjectType, richObject, accessible, interactive }) => {
const { default: Vue } = await import('vue')
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions templates/appointments/booking-conflict.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-appointments-conflict');
style(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-style');

?>

Expand Down
1 change: 1 addition & 0 deletions templates/appointments/booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

script(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-appointments-booking');
style(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-style');

?>

Expand Down
1 change: 1 addition & 0 deletions templates/appointments/confirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-appointments-confirmation');
style(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-style');

?>

Expand Down
1 change: 1 addition & 0 deletions templates/appointments/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

script(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-appointments-overview');
style(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-style');

?>

Expand Down
1 change: 1 addition & 0 deletions templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script('calendar', 'calendar-main');
style('calendar', 'calendar-style');
25 changes: 25 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import path from 'path'
import { createAppConfig } from '@nextcloud/vite-config'

export default createAppConfig({
main: path.join(__dirname, 'src', 'main.js'),
dashboard: path.join(__dirname, 'src', 'dashboard.js'),
reference: path.join(__dirname, 'src', 'reference.js'),
'appointments-booking': path.join(__dirname, 'src', 'appointments/main-booking.js'),
'appointments-confirmation': path.join(__dirname, 'src', 'appointments/main-confirmation.js'),
'appointments-conflict': path.join(__dirname, 'src', 'appointments/main-conflict.js'),
'appointments-overview': path.join(__dirname, 'src', 'appointments/main-overview.js'),
}, {
// Move all css to a single chunk (calendar-style.css)
inlineCSS: false,
config: {
build: {
cssCodeSplit: false,
},
},
})
54 changes: 0 additions & 54 deletions webpack.config.js

This file was deleted.

Loading