Skip to content

Commit

Permalink
build: separate app and lib configs (#112)
Browse files Browse the repository at this point in the history
* build: separate app and lib configs

* ci: run both builds

* revert: remove explicit dependency
  • Loading branch information
tpluscode authored Jun 25, 2024
1 parent 97f400d commit 8c8d870
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
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'
}
},
})

0 comments on commit 8c8d870

Please sign in to comment.