WIP: first take on building package with vite

Signed-off-by: Max <max@nextcloud.com>
This commit is contained in:
Max 2022-05-12 06:00:07 +02:00
Родитель ef7b0fdfd6
Коммит 59316d66be
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0F5BFA367A00BACE
5 изменённых файлов: 94 добавлений и 1 удалений

38
index.html Normal file
Просмотреть файл

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="/dist/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test the package</title>
</head>
<body>
<div id="app"></div>
<script type="module">
import { ReadOnlyEditor } from './src/package.js'
import Vue from 'vue'
const app = new Vue({
data() {
return {
content: '**Hello There**',
}
},
render: (h) => h('div', [
h(ReadOnlyEditor, {
props: { content: app.content }
}),
h('textarea', {
attrs: { rows: 20, cols: 80 },
on: {
input: function (event) {
app.content = event.target.value
},
},
}, [app.content]),
]),
})
app.$mount('#app')
</script>
</body>
</html>

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

@ -13,8 +13,10 @@
"private": true,
"scripts": {
"dev": "NODE_ENV=development webpack --config webpack.js",
"dev:package": "vite",
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
"build": "NODE_ENV=production webpack --progress --config webpack.js",
"build:package": "vite build",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css",
@ -88,6 +90,7 @@
"prosemirror-view": "^1.23.13",
"proxy-polyfill": "^0.3.2",
"tippy.js": "^6.3.7",
"vite-plugin-vue2": "^2.0.0",
"vue": "^2.6.14",
"vue-click-outside": "^1.1.0",
"vue-material-design-icons": "^5.0.0",
@ -123,6 +126,7 @@
"jest-raw-loader": "^1.0.1",
"jest-serializer-vue": "^2.0.2",
"regenerator-runtime": "^0.13.9",
"vite": "^2.9.9",
"webpack": "^5.73.0"
},
"jest": {

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

@ -33,11 +33,13 @@ import CodeBlock from '@tiptap/extension-code-block'
import HorizontalRule from '@tiptap/extension-horizontal-rule'
import Dropcursor from '@tiptap/extension-dropcursor'
import HardBreak from './HardBreak.js'
/*
import Table from './../nodes/Table.js'
import TableCell from './../nodes/TableCell.js'
import TableHeader from './../nodes/TableHeader.js'
import TableHeadRow from './../nodes/TableHeadRow.js'
import TableRow from './../nodes/TableRow.js'
*/
/* eslint-enable import/no-named-as-default */
import { Strong, Italic, Strike, Link, Underline } from './../marks/index.js'
@ -75,11 +77,12 @@ export default Extension.create({
HorizontalRule,
OrderedList,
ListItem,
Table,
/* Table,
TableCell,
TableHeader,
TableHeadRow,
TableRow,
*/
TaskList,
TaskItem,
Callout,

25
src/package.js Normal file
Просмотреть файл

@ -0,0 +1,25 @@
/*
* @copyright Copyright (c) 2022 Max <max@nextcloud.com>
*
* @author Max <max@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import ReadOnlyEditor from './components/ReadOnlyEditor.vue'
export { ReadOnlyEditor }

23
vite.config.js Normal file
Просмотреть файл

@ -0,0 +1,23 @@
import { resolve } from 'path'
import { defineConfig } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'
import { dependencies } from './package.json'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [createVuePlugin()],
build: {
lib: {
entry: resolve(__dirname, 'src/package.js'),
name: '@nextcloud/text',
fileName: 'index.js',
formats: ['es'],
},
rollupOptions: {
external: Object.keys(dependencies),
output: {
globals: { vue: 'Vue' }
},
},
},
})