-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
66 lines (60 loc) · 2.54 KB
/
Copy pathwebpack.config.js
File metadata and controls
66 lines (60 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* SPDX-FileCopyrightText: 2024 LaunchPad Contributors
* SPDX-License-Identifier: EUPL-1.2
*/
const path = require('path')
const fs = require('fs')
const webpackConfig = require('@nextcloud/webpack-vue-config')
webpackConfig.entry = {
main: path.join(__dirname, 'src', 'main.js'),
admin: path.join(__dirname, 'src', 'admin.js'),
// Anonymous read-only public-share page (/apps/launchpad/s/{token}).
public: path.join(__dirname, 'src', 'public.js'),
}
webpackConfig.output = {
...webpackConfig.output,
filename: 'launchpad-[name].js',
chunkFilename: 'launchpad-[name].js?v=[contenthash]',
}
// Use local source when available (monorepo dev), otherwise fall back to npm package
const localLib = path.resolve(__dirname, '../nextcloud-vue/src')
const useLocalLib = fs.existsSync(localLib)
webpackConfig.resolve = {
...(webpackConfig.resolve || {}),
alias: {
...(webpackConfig.resolve?.alias || {}),
...(useLocalLib ? { '@conduction/nextcloud-vue': localLib } : {}),
// Deduplicate shared packages so the aliased library source uses
// the same instances as the app (prevents dual-Pinia / dual-Vue bugs).
vue$: path.resolve(__dirname, 'node_modules/vue'),
pinia$: path.resolve(__dirname, 'node_modules/pinia'),
// @nextcloud/vue@9 and @nextcloud/dialogs@7 (the Vue-3 lines) are
// ESM-only: no `main`/`module`, just an `exports` map with a single
// "import" condition. Aliasing to the package DIRECTORY (as before)
// bypasses `exports` and looks for a main/index that does not exist,
// so every import fails to resolve. Point at the concrete ESM entry.
// The `$` keeps deep imports (`@nextcloud/vue/components/NcButton`)
// going through the exports map.
'@nextcloud/vue$': path.resolve(
__dirname,
'node_modules/@nextcloud/vue/dist/index.mjs',
),
'@nextcloud/dialogs$': path.resolve(
__dirname,
'node_modules/@nextcloud/dialogs/dist/index.mjs',
),
// `@nextcloud/axios@2.6+` is ESM-only and its `exports` map has no
// `require` condition, so the CJS bundle of `@nextcloud/vue@8.x`
// (which does `require('@nextcloud/axios')`) fails to resolve.
// Alias directly to the ESM entry so webpack bypasses the exports
// map and transforms/interops the ESM module itself.
'@nextcloud/axios$': path.resolve(
__dirname,
'node_modules/@nextcloud/axios/dist/index.js',
),
},
// Ensure webpack resolves dependencies from the app's node_modules first,
// preventing Vue 3 packages from nextcloud-vue/node_modules leaking in.
modules: [path.resolve(__dirname, 'node_modules'), 'node_modules'],
}
module.exports = webpackConfig