-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tmp: copy the extension-sdk while it's not published
- Loading branch information
Showing
10 changed files
with
124 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// ATTENTION: this is a .mjs (instead of a .ts) file on purpose, | ||
// because we don't want to transpile it before publishing | ||
// c.f. https://github.com/vitejs/vite/issues/5370 | ||
|
||
import { mergeConfig, searchForWorkspaceRoot } from 'vite' | ||
import { join } from 'path' | ||
import { cwd } from 'process' | ||
import { readFileSync } from 'fs' | ||
|
||
import vue from '@vitejs/plugin-vue' | ||
import serve from 'rollup-plugin-serve' | ||
|
||
const distDir = 'dist' | ||
|
||
export const defineConfig = (overrides = {}) => { | ||
return ({ mode }) => { | ||
const isProduction = mode === 'production' | ||
const isServing = !isProduction | ||
|
||
// read package name from vite workspace | ||
const packageJson = JSON.parse( | ||
readFileSync(join(searchForWorkspaceRoot(cwd()), 'package.json')).toString() | ||
) | ||
|
||
const name = packageJson.name | ||
|
||
// take vite standard config and reuse it for rollup-plugin-serve config | ||
const { https, port = 9210, host = 'localhost' } = overrides?.server | ||
const isHttps = !!https | ||
|
||
if (isServing) { | ||
console.log( | ||
`>>> Serving extension at http${isHttps ? 's' : ''}://${host}:${port}/js/${name}.js` | ||
) | ||
} | ||
|
||
return mergeConfig( | ||
{ | ||
server: { | ||
host, | ||
port, | ||
strictPort: true | ||
}, | ||
resolve: { | ||
alias: { | ||
path: 'rollup-plugin-node-polyfills/polyfills/path' | ||
} | ||
}, | ||
build: { | ||
cssCodeSplit: true, | ||
minify: isProduction, | ||
rollupOptions: { | ||
external: ['vue', 'vuex', 'luxon', 'web-pkg', 'web-client', 'vue3-gettext'], | ||
preserveEntrySignatures: 'strict', | ||
input: { | ||
[name]: './src/index.ts' | ||
}, | ||
output: { | ||
format: 'amd', | ||
dir: distDir, | ||
chunkFileNames: join('js', 'chunks', '[name]-[hash].mjs'), | ||
entryFileNames: join('js', `[name]${isProduction ? '-[hash]' : ''}.js`) | ||
}, | ||
plugins: [ | ||
isServing && | ||
serve({ | ||
headers: { | ||
'access-control-allow-origin': '*' | ||
}, | ||
contentBase: distDir, | ||
...(https && { https }), | ||
...(port && { port }) | ||
}) | ||
] | ||
} | ||
}, | ||
plugins: [ | ||
vue({ | ||
customElement: false | ||
}) | ||
] | ||
}, | ||
overrides | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "@ownclouders/extension-sdk", | ||
"version": "0.0.1-alpha.1", | ||
"description": "ownCloud Web Extension SDK", | ||
"license": "AGPL-3.0", | ||
"main": "index.mjs", | ||
"type": "module", | ||
"private": false, | ||
"author": "ownCloud GmbH <[email protected]>", | ||
"homepage": "https://github.com/owncloud/web/tree/master/packages/extension-sdk", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/owncloud/web", | ||
"directory": "packages/extension-sdk" | ||
}, | ||
"dependencies": { | ||
"@vitejs/plugin-vue": "4.0.0", | ||
"rollup-plugin-node-polyfills": "^0.2.1", | ||
"rollup-plugin-serve": "^2.0.2" | ||
}, | ||
"peerDependencies": { | ||
"vite": "^4.1.1", | ||
"sass": "1.58.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters