chore(webpack): Move to shared code for entrypoints and use webpack serve public path

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2023-05-17 09:49:22 +02:00
Родитель 9f753e4395
Коммит d096208f58
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
8 изменённых файлов: 28 добавлений и 22 удалений

Просмотреть файл

@ -23,6 +23,8 @@
import { subscribe } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
import './shared-init.js'
subscribe('calendar:handle-todo-click', ({ calendarId, taskId }) => {
const deckAppPrefix = 'app-generated--deck--board-'
if (calendarId.startsWith(deckAppPrefix)) {

Просмотреть файл

@ -26,10 +26,7 @@ import './../css/collections.css'
import FileSharingPicker from './views/FileSharingPicker.js'
import { buildSelector } from './helpers/selector.js'
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken);
// eslint-disable-next-line
__webpack_public_path__ = OC.linkTo('deck', 'js/');
import './shared-init.js'
Vue.prototype.t = t
Vue.prototype.n = n

Просмотреть файл

@ -22,12 +22,9 @@
import './css/dashboard.scss'
const debug = process.env.NODE_ENV !== 'production'
import './shared-init.js'
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken);
// eslint-disable-next-line
__webpack_public_path__ = OC.linkTo('deck', 'js/');
const debug = process.env.NODE_ENV !== 'production'
document.addEventListener('DOMContentLoaded', () => {
OCA.Dashboard.register('deck', async (el) => {

Просмотреть файл

@ -28,6 +28,8 @@ import CommentReferenceWidget from './views/CommentReferenceWidget.vue'
import { translate, translatePlural } from '@nextcloud/l10n'
import './shared-init.js'
Vue.prototype.t = translate
Vue.prototype.n = translatePlural
Vue.prototype.OC = window.OC

Просмотреть файл

@ -27,10 +27,7 @@ import CardCreateDialog from './CardCreateDialog.vue'
import { buildSelector } from './helpers/selector.js'
import './init-collections.js'
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken);
// eslint-disable-next-line
__webpack_public_path__ = OC.linkTo('deck', 'js/');
import './shared-init.js'
Vue.prototype.t = t
Vue.prototype.n = n

Просмотреть файл

@ -25,23 +25,17 @@ import router from './router.js'
import store from './store/main.js'
import { sync } from 'vuex-router-sync'
import { translate, translatePlural } from '@nextcloud/l10n'
import { generateFilePath } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import { subscribe } from '@nextcloud/event-bus'
import { Tooltip } from '@nextcloud/vue'
import ClickOutside from 'vue-click-outside'
import './shared-init.js'
import './models/index.js'
import './sessions.js'
// the server snap.js conflicts with vertical scrolling so we disable it
document.body.setAttribute('data-snap-ignore', 'true')
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken)
if (!process.env.HOT) {
// eslint-disable-next-line
__webpack_public_path__ = generateFilePath('deck', '', 'js/')
}
sync(store, router)
Vue.prototype.t = translate

12
src/shared-init.js Normal file
Просмотреть файл

@ -0,0 +1,12 @@
import { generateFilePath } from '@nextcloud/router'
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken)
if (!process.env.WEBPACK_SERVE) {
// eslint-disable-next-line
__webpack_public_path__ = generateFilePath('deck', '', 'js/')
} else {
// eslint-disable-next-line
__webpack_public_path__ = 'http://127.0.0.1:3000/'
}

Просмотреть файл

@ -1,9 +1,9 @@
const webpackConfig = require('@nextcloud/webpack-vue-config')
const webpack = require('webpack')
const path = require('path')
const buildMode = process.env.NODE_ENV
const isDev = buildMode === 'development'
const isDevServer = process.env.WEBPACK_DEV_SERVER;
const isDevServer = process.env.WEBPACK_SERVE
webpackConfig.entry = {
...webpackConfig.entry,
@ -16,6 +16,11 @@ webpackConfig.entry = {
if (isDevServer) {
webpackConfig.output.publicPath = 'http://127.0.0.1:3000/'
webpackConfig.plugins.push(
new webpack.DefinePlugin({
'process.env.WEBPACK_SERVE': true,
})
)
} else {
webpackConfig.stats = {
context: path.resolve(__dirname, 'src'),