Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: separate app and lib configs #112

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ jobs:
run: npm ci

- name: Build the app
run: npm run build
run: npm run build:app

- name: Build in lib mode
run: npm run build:lib

lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: npm ci

- name: Build the app
run: npm run build
run: npm run build:app

- name: Configure CNAME
run: echo spex.zazuko.com > dist/CNAME
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"type": "module",
"scripts": {
"serve": "vite",
"build": "vite build",
"build:app": "vite build",
"build:lib": "vite build -c vite.umd.config.js",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
"prepack": "npm run build",
"prepack": "npm run build:lib",
"release": "changeset publish"
},
"main": "dist/spex.js",
Expand Down
4 changes: 3 additions & 1 deletion src/registerServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import { register } from 'register-service-worker'

const baseUrl = process.env.BASE_URL || ''

if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
register(`${baseUrl}/sw.js`, {
ready() {
console.log(
'App is being served from cache by a service worker.\n' +
Expand Down
4 changes: 2 additions & 2 deletions src/views/ShaclEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'
import '@rdfjs-elements/rdf-editor'
import rdfEnvironment from '@zazuko/env/web'
import { tablesFromSHACL } from '../shacl.js'
import { rdf, sh } from '../namespace.js'
import { tablesFromSHACL } from '../shacl'
import { rdf, sh } from '../namespace'
import ResourceCard from '../components/ResourceCard.vue'

const formats = [...parsers.keys()]
Expand Down
15 changes: 2 additions & 13 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineConfig } from 'vite'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'

Expand Down Expand Up @@ -73,16 +72,6 @@ export default defineConfig({
},
build: {
outDir: '../dist',
sourcemap: true,
rollupOptions: {
plugins: [
rollupNodePolyFill(),
],
},
lib: {
entry: 'index.ts',
name: 'spex',
fileName: 'spex'
}
},
emptyOutDir: true,
}
})
23 changes: 23 additions & 0 deletions vite.umd.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from 'vite'
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
import config from './vite.config.js'

// https://vitejs.dev/config/
export default defineConfig({
...config,
build: {
outDir: '../dist',
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
plugins: [
rollupNodePolyFill(),
],
},
lib: {
entry: 'index.ts',
name: 'spex',
fileName: 'spex'
}
},
})