@opencloud-eu/extension-sdk 4.1.0-alpha.1 → 4.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/index.mjs +38 -5
- package/package.json +1 -1
- package/tailwind.css +14 -0
package/README.md
CHANGED
|
@@ -37,3 +37,11 @@ export default defineConfig({
|
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
```
|
|
40
|
+
|
|
41
|
+
### Tailwind CSS
|
|
42
|
+
|
|
43
|
+
The extension-sdk comes with a preconfigured Tailwind CSS setup for extension development. To use it, simply import the provided CSS file in your main application file. Note that Tailwind classes need to be prefixed via `ext:` in extensions to avoid style conflicts.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import '@opencloud-eu/extension-sdk/tailwind.css'
|
|
47
|
+
```
|
package/index.mjs
CHANGED
|
@@ -79,6 +79,37 @@ const manifestPlugin = () => {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// UPSTREAM: https://github.com/vitejs/vite/pull/20861
|
|
83
|
+
// We are trying to upstream this plugin, it can be removed once the PR above or an alternative approach has been merged
|
|
84
|
+
// TL;DR of the issue: vite uses the require variable for certain features but doesn't ensure it's injected into AMD modules
|
|
85
|
+
// thus the global require variable is used which does not have the correct base path set, so relative imports
|
|
86
|
+
// with ?url or ?worker break
|
|
87
|
+
const completeAmdWrapPlugin = () => {
|
|
88
|
+
const AmdWrapRE = /\bdefine\((?:\s*\[([^\]]*)\],)?\s*(?:\(\s*)?function\s*\(([^)]*)\)\s*\{/
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
name: 'vite:force-amd-wrap-require',
|
|
92
|
+
enforce: 'pre',
|
|
93
|
+
renderChunk(code, _chunk, opts) {
|
|
94
|
+
if (opts.format !== 'amd') return
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
code: code.replace(AmdWrapRE, (_, deps, params) => {
|
|
98
|
+
if (deps?.includes('"require"')) {
|
|
99
|
+
return `define([${deps}], (function(${params}) {`
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const newDeps = deps ? `"require", ${deps}` : '"require"'
|
|
103
|
+
const newParams = params.trim() ? `require, ${params}` : 'require'
|
|
104
|
+
|
|
105
|
+
return `define([${newDeps}], (function(${newParams}) {`
|
|
106
|
+
}),
|
|
107
|
+
map: null // no need to generate sourcemap as no mapping exists for the wrapper
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
82
113
|
export const defineConfig = (overrides = {}) => {
|
|
83
114
|
return ({ mode }) => {
|
|
84
115
|
const isProduction = mode === 'production'
|
|
@@ -97,11 +128,7 @@ export const defineConfig = (overrides = {}) => {
|
|
|
97
128
|
|
|
98
129
|
return mergeConfig(
|
|
99
130
|
{
|
|
100
|
-
|
|
101
|
-
port,
|
|
102
|
-
strictPort: true,
|
|
103
|
-
...(isHttps && https)
|
|
104
|
-
},
|
|
131
|
+
base: './', // make asset paths relative so imports work from wherever the extension is loaded
|
|
105
132
|
build: {
|
|
106
133
|
cssCodeSplit: true,
|
|
107
134
|
minify: isProduction,
|
|
@@ -136,6 +163,7 @@ export const defineConfig = (overrides = {}) => {
|
|
|
136
163
|
}
|
|
137
164
|
},
|
|
138
165
|
plugins: [
|
|
166
|
+
completeAmdWrapPlugin(),
|
|
139
167
|
vue({
|
|
140
168
|
// set to true when switching to esm
|
|
141
169
|
customElement: false,
|
|
@@ -144,6 +172,11 @@ export const defineConfig = (overrides = {}) => {
|
|
|
144
172
|
manifestPlugin(),
|
|
145
173
|
tailwindcss()
|
|
146
174
|
],
|
|
175
|
+
server: {
|
|
176
|
+
port,
|
|
177
|
+
strictPort: true,
|
|
178
|
+
...(isHttps && https)
|
|
179
|
+
},
|
|
147
180
|
test: {
|
|
148
181
|
globals: true,
|
|
149
182
|
environment: 'happy-dom',
|
package/package.json
CHANGED
package/tailwind.css
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@layer theme, base, components, utilities;
|
|
2
|
+
@import 'tailwindcss/theme.css' layer(theme) prefix(ext);
|
|
3
|
+
@import 'tailwindcss/utilities.css' layer(utilities) prefix(ext);
|
|
4
|
+
|
|
5
|
+
@theme {
|
|
6
|
+
--font-sans: var(--oc-font-family);
|
|
7
|
+
|
|
8
|
+
--spacing: 4px;
|
|
9
|
+
--breakpoint-xs: 580px;
|
|
10
|
+
--breakpoint-sm: 640px;
|
|
11
|
+
--breakpoint-md: 960px;
|
|
12
|
+
--breakpoint-lg: 1200px;
|
|
13
|
+
--breakpoint-xl: 1600px;
|
|
14
|
+
}
|