From db8631bed06bfb4e687c2fe9c179093c04bf882d Mon Sep 17 00:00:00 2001 From: Chris Campbell Date: Wed, 29 May 2024 20:26:15 -0700 Subject: [PATCH] fix: remove playground sources from this branch --- examples/playground/.eslintignore | 1 - examples/playground/.eslintrc.cjs | 3 - examples/playground/.gitignore | 1 - examples/playground/.prettierignore | 2 - examples/playground/LICENSE | 21 -- examples/playground/index.html | 13 -- examples/playground/package.json | 48 ---- examples/playground/src/app-vm.ts | 218 ------------------ examples/playground/src/app.svelte | 81 ------- .../src/components/_shared/selector-vm.ts | 35 --- .../src/components/_shared/selector.svelte | 59 ----- .../src/components/graph/graph-view.ts | 175 -------------- .../src/components/graph/graph-vm.ts | 19 -- .../src/components/graph/graph.svelte | 87 ------- examples/playground/src/global.css | 4 - examples/playground/src/index.ts | 7 - examples/playground/src/types.d.ts | 2 - examples/playground/svelte.config.js | 17 -- examples/playground/tsconfig-base.json | 16 -- examples/playground/tsconfig-build.json | 9 - examples/playground/tsconfig-test.json | 5 - examples/playground/tsconfig.json | 6 - examples/playground/vite.config.js | 86 ------- 23 files changed, 915 deletions(-) delete mode 100644 examples/playground/.eslintignore delete mode 100644 examples/playground/.eslintrc.cjs delete mode 100644 examples/playground/.gitignore delete mode 100644 examples/playground/.prettierignore delete mode 100644 examples/playground/LICENSE delete mode 100644 examples/playground/index.html delete mode 100644 examples/playground/package.json delete mode 100644 examples/playground/src/app-vm.ts delete mode 100644 examples/playground/src/app.svelte delete mode 100644 examples/playground/src/components/_shared/selector-vm.ts delete mode 100644 examples/playground/src/components/_shared/selector.svelte delete mode 100644 examples/playground/src/components/graph/graph-view.ts delete mode 100644 examples/playground/src/components/graph/graph-vm.ts delete mode 100644 examples/playground/src/components/graph/graph.svelte delete mode 100644 examples/playground/src/global.css delete mode 100644 examples/playground/src/index.ts delete mode 100644 examples/playground/src/types.d.ts delete mode 100644 examples/playground/svelte.config.js delete mode 100644 examples/playground/tsconfig-base.json delete mode 100644 examples/playground/tsconfig-build.json delete mode 100644 examples/playground/tsconfig-test.json delete mode 100644 examples/playground/tsconfig.json delete mode 100644 examples/playground/vite.config.js diff --git a/examples/playground/.eslintignore b/examples/playground/.eslintignore deleted file mode 100644 index a48cf0de..00000000 --- a/examples/playground/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -public diff --git a/examples/playground/.eslintrc.cjs b/examples/playground/.eslintrc.cjs deleted file mode 100644 index 91ab6eef..00000000 --- a/examples/playground/.eslintrc.cjs +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extends: ['../../.eslintrc-svelte-common.cjs'] -} diff --git a/examples/playground/.gitignore b/examples/playground/.gitignore deleted file mode 100644 index a48cf0de..00000000 --- a/examples/playground/.gitignore +++ /dev/null @@ -1 +0,0 @@ -public diff --git a/examples/playground/.prettierignore b/examples/playground/.prettierignore deleted file mode 100644 index 1f6c1701..00000000 --- a/examples/playground/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -public -**/*.svelte diff --git a/examples/playground/LICENSE b/examples/playground/LICENSE deleted file mode 100644 index 4cbef729..00000000 --- a/examples/playground/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2024 Climate Interactive / New Venture Fund - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/examples/playground/index.html b/examples/playground/index.html deleted file mode 100644 index 02b682e5..00000000 --- a/examples/playground/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - SDEverywhere Playground - - - - - - - - - diff --git a/examples/playground/package.json b/examples/playground/package.json deleted file mode 100644 index 5e2776d8..00000000 --- a/examples/playground/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@sdeverywhere/playground", - "private": true, - "version": "1.0.0", - "type": "module", - "scripts": { - "clean": "rm -rf public", - "lint:ts": "eslint src --max-warnings 0", - "lint:svelte": "svelte-check --fail-on-warnings --output human --compiler-warnings \"a11y-click-events-have-key-events:ignore,a11y-no-noninteractive-tabindex:ignore\"", - "lint": "run-s lint:ts lint:svelte", - "prettier:check": "prettier --check .", - "prettier:fix": "prettier --write .", - "precommit": "../../scripts/precommit", - "test": "echo No tests yet", - "type-check": "tsc --noEmit -p tsconfig-build.json", - "build": "vite build", - "dev": "vite", - "ci:build": "run-s clean lint prettier:check type-check build" - }, - "dependencies": { - "@sdeverywhere/compile": "workspace:*", - "@sdeverywhere/runtime": "workspace:*", - "chart.js": "^2.9.4" - }, - "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^2.4.5", - "@types/chart.js": "^2.9.34", - "postcss": "^8.4.31", - "pug": "^3.0.1", - "sass": "^1.34.1", - "svelte": "^3.59.2", - "svelte-check": "^3.5.1", - "svelte-preprocess": "^5.0.4", - "vite": "^4.4.9", - "vite-plugin-node-polyfills": "^0.21.0" - }, - "author": "Climate Interactive", - "license": "MIT", - "homepage": "https://sdeverywhere.org", - "repository": { - "type": "git", - "url": "https://github.com/climateinteractive/SDEverywhere.git", - "directory": "examples/playground" - }, - "bugs": { - "url": "https://github.com/climateinteractive/SDEverywhere/issues" - } -} diff --git a/examples/playground/src/app-vm.ts b/examples/playground/src/app-vm.ts deleted file mode 100644 index 498648cd..00000000 --- a/examples/playground/src/app-vm.ts +++ /dev/null @@ -1,218 +0,0 @@ -import { derived, writable, type Readable, type Writable } from 'svelte/store' - -import { - generateJS, - getModelListing, - parseInlineVensimModel, - resetState as resetCompileState -} from '@sdeverywhere/compile' - -import { - createRunnableModel, - createSynchronousModelRunner, - type JsModel, - type ModelRunner, - type Outputs -} from '@sdeverywhere/runtime' - -import { SelectorOptionViewModel, SelectorViewModel } from './components/_shared/selector-vm' -import type { GraphViewModel } from './components/graph/graph-vm' - -const initialMdl = `\ -x = TIME ~~| - -y = x * x ~~| - -INITIAL TIME = 0 ~~| -FINAL TIME = 5 ~~| -TIME STEP = 1 ~~| -SAVEPER = 1 ~~| -` - -export interface VarInfo { - refId: string - varName: string - references: string[] - hasInitValue: boolean - varType: 'const' | 'data' | 'aux' | 'level' - modelLHS: string - modelFormula: string - varIndex?: number -} - -export interface GeneratedModelInfo { - jsCode: string - // jsonList: string - inputVars: VarInfo[] - outputVars: VarInfo[] -} - -interface GeneratedModel { - info: GeneratedModelInfo - runner: ModelRunner - outputs: Outputs -} - -export class AppViewModel { - private readonly writableSourceModel: Writable - public readonly sourceModel: Readable - - private readonly writableGeneratedModel: Writable - - private readonly writableSelectedVarId: Writable - private readonly writableVarSelector: Writable - public readonly varSelector: Readable - - public readonly generatedModelInfo: Readable - public readonly selectedVarGraph: Readable - - constructor() { - this.writableSourceModel = writable(initialMdl) - this.sourceModel = this.writableSourceModel - - this.writableGeneratedModel = writable(undefined) - - this.writableSelectedVarId = writable(undefined) - this.writableVarSelector = writable(undefined) - this.varSelector = this.writableVarSelector - - this.generatedModelInfo = derived(this.writableGeneratedModel, $generatedModel => { - return $generatedModel?.info - }) - - // Update the graph data when the model changes or when a new variable is selected - // TODO: Update outputs when constant or lookup is overridden - let graphKey = 0 - this.selectedVarGraph = derived( - [this.writableGeneratedModel, this.writableSelectedVarId], - ([$generatedModel, $selectedVarId]) => { - if ($generatedModel === undefined || $selectedVarId === undefined) { - return undefined - } - - const outputs = $generatedModel.outputs - $generatedModel.runner.runModelSync([], outputs) - - return { - key: `${graphKey++}`, - points: outputs.getSeriesForVar($selectedVarId)?.points || [] - } - } - ) - - // XXX: Use a proper async-friendly store here - this.sourceModel.subscribe(async $sourceModel => { - await this.setSourceModel($sourceModel) - }) - } - - private async setSourceModel(mdl: string): Promise { - // Reset state - this.writableGeneratedModel.set(undefined) - this.writableSelectedVarId.set(undefined) - - // Read the model and generate JS code - const generatedModelInfo = readInlineModelAndGenerateJS(mdl) - - // Initialize a model runner - const runner = await initModelRunner(generatedModelInfo.jsCode) - const outputs = runner.createOutputs() - this.writableGeneratedModel.set({ - info: generatedModelInfo, - runner, - outputs - }) - - // Update the variable selector and select the first variable by default - const outputVarIds = generatedModelInfo.outputVars.map(varInfo => varInfo.refId) || [] - const options = outputVarIds.map(varId => new SelectorOptionViewModel(varId, varId)) - if (outputVarIds.length > 0) { - // TODO: Preserve previous selection if possible - const selectedVarId = outputVarIds[0] - this.writableSelectedVarId.set(selectedVarId) - this.writableVarSelector.set(new SelectorViewModel(options, this.writableSelectedVarId)) - } else { - this.writableSelectedVarId.set(undefined) - this.writableVarSelector.set(undefined) - } - } -} - -function readInlineModelAndGenerateJS( - mdlContent: string, - opts?: { - inputVarNames?: string[] - outputVarNames?: string[] - } -): GeneratedModelInfo { - // XXX: This step is needed due to subs/dims and variables being in module-level storage - resetCompileState() - - let spec - if (opts?.inputVarNames || opts?.outputVarNames) { - spec = { - inputVarNames: opts?.inputVarNames || [], - outputVarNames: opts?.outputVarNames || [] - } - } else { - spec = {} - } - - // Parse the Vensim model - const parsedModel = parseInlineVensimModel(mdlContent /*, opts?.modelDir*/) - - // Generate JS code - const jsCode = generateJS(parsedModel, { - spec, - operations: ['generateJS'] - // extData: opts?.extData, - // directData, - // modelDirname: opts?.modelDir - }) - - // Parse the JSON listing to determine input and output variables - const jsonListStr = getModelListing() - const listing = JSON.parse(jsonListStr) - const inputVars = [] - const outputVars = [] - for (const varInfo of listing.variables) { - // Ignore control variables - switch (varInfo.varName) { - case '_final_time': - case '_initial_time': - case '_time_step': - case '_saveper': - continue - default: - break - } - - switch (varInfo.varType) { - case 'const': - inputVars.push(varInfo) - break - case 'aux': - case 'level': - outputVars.push(varInfo) - break - default: - break - } - } - - return { - jsCode, - inputVars, - outputVars - } -} - -async function initModelRunner(modelJs: string): Promise { - const dataUri = 'data:text/javascript;charset=utf-8,' + encodeURIComponent(modelJs) - // TODO: Fix this so that we don't need the vite-ignore - const generatedModule = await import(/* @vite-ignore */ dataUri) - const generatedModel = (await generatedModule.default()) as JsModel - // console.log(generatedModel) - const runnableModel = createRunnableModel(generatedModel) - return createSynchronousModelRunner(runnableModel) -} diff --git a/examples/playground/src/app.svelte b/examples/playground/src/app.svelte deleted file mode 100644 index 3d6a4a5c..00000000 --- a/examples/playground/src/app.svelte +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/playground/src/components/_shared/selector-vm.ts b/examples/playground/src/components/_shared/selector-vm.ts deleted file mode 100644 index 43423789..00000000 --- a/examples/playground/src/components/_shared/selector-vm.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { Writable } from 'svelte/store' - -/** View model for an option in a selector control. */ -export class SelectorOptionViewModel { - /** - * @param label The displayed string. - * @param value The value for the option. - * @param disabled Whether the option is disabled. - * @param hidden Whether the option is hidden when the popup menu - * is visible (this is browser dependent; may not work in Safari). - */ - constructor( - public readonly label: string, - public readonly value: string, - public readonly disabled = false, - public readonly hidden = false - ) {} -} - -/** View model for a dropdown/selector control. */ -export class SelectorViewModel { - /** Called when the user has changed the value. */ - public onUserChange?: (newValue: string) => void - - /** - * @param options The options for the selector. - * @param selectedValue The value of the selected option. - * @param labelKey The key for the label (optional). - */ - constructor( - public readonly options: SelectorOptionViewModel[], - public readonly selectedValue: Writable, - public readonly label?: string - ) {} -} diff --git a/examples/playground/src/components/_shared/selector.svelte b/examples/playground/src/components/_shared/selector.svelte deleted file mode 100644 index 3a6fa443..00000000 --- a/examples/playground/src/components/_shared/selector.svelte +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/examples/playground/src/components/graph/graph-view.ts b/examples/playground/src/components/graph/graph-view.ts deleted file mode 100644 index c0739b7f..00000000 --- a/examples/playground/src/components/graph/graph-view.ts +++ /dev/null @@ -1,175 +0,0 @@ -import type { ChartDataSets } from 'chart.js' -import { Chart } from 'chart.js' - -import type { GraphViewModel, PlotStyle, Point } from './graph-vm' - -const gridColor = '#444' -const fontFamily = 'sans-serif' -const fontSize = 14 -const fontColor = '#777' - -/** - * Wraps a native chart element. - */ -export class GraphView { - private chart: Chart - - constructor(readonly canvas: HTMLCanvasElement, readonly viewModel: GraphViewModel) { - this.chart = createChart(canvas, viewModel) - } - - /** - * Destroy the chart and any associated resources. - */ - destroy(): void { - this.chart?.destroy() - this.chart = undefined - } -} - -function createChart(canvas: HTMLCanvasElement, viewModel: GraphViewModel): Chart { - const datasets: ChartDataSets[] = [] - - function addPlot(points: Point[], color: string, style?: PlotStyle): void { - const normalWidth = 3 - let borderWidth = normalWidth - if (style) { - // Use thin reference lines - borderWidth = 1 - } - - let borderDash: number[] - // let fill: string | boolean = false - switch (style) { - case 'wide': - borderWidth = normalWidth * 2 - break - case 'dashed': - borderDash = [8, 2] - break - // case 'fill-to-next': - // fill = '+1' - // break - // case 'fill-above': - // fill = 'end' - // break - // case 'fill-below': - // fill = 'start' - // break - default: - break - } - - // let backgroundColor = undefined - // if (fill !== false) { - // // Make the fill less translucent when there is only a single point - // const opacity = points.length > 1 ? 0.1 : 0.3 - // backgroundColor = `rgba(0, 128, 0, ${opacity})` - // } - - let pointRadius = 0 - let pointBackgroundColor = undefined - if (points.length === 1 && style !== 'dashed') { - pointRadius = 5 - pointBackgroundColor = color - } - - datasets.push({ - data: points, - borderColor: color, - borderWidth, - borderDash, - // backgroundColor, - // fill, - pointRadius, - pointBackgroundColor, - pointBorderWidth: 0, - pointBorderColor: 'transparent', - lineTension: 0 - }) - } - - // Add the plots - addPlot(viewModel.points, 'deepskyblue') - // for (const refPlot of viewModel.refPlots) { - // addPlot(refPlot.points, 'green', refPlot.style || 'normal') - // } - - // Customize the x-axis range - const xMin = viewModel.xMin - const xMax = viewModel.xMax - // XXX: Omit the 1990 label to avoid overlap issues - const omitFirstTick = xMin === 1990 - - return new Chart(canvas, { - type: 'line', - data: { - datasets - }, - options: { - // Use built-in responsive resizing support. Note that for this to work - // correctly, the canvas parent must be a container with a fixed size - // (in `vw` or `px` units) and `position: relative`. For more information: - // https://www.chartjs.org/docs/latest/general/responsive.html - responsive: true, - maintainAspectRatio: false, - - // Disable animation - animation: { duration: 0 }, - hover: { animationDuration: 0 }, - responsiveAnimationDuration: 0, - - // Disable the built-in title and legend - title: { display: false }, - legend: { display: false }, - - // Don't show points - elements: { - point: { - radius: 0 - } - }, - - // Customize tooltip font - tooltips: { - titleFontFamily: fontFamily, - bodyFontFamily: fontFamily - }, - - // Axis configurations - scales: { - xAxes: [ - { - type: 'linear', - position: 'bottom', - gridLines: { - color: gridColor - }, - ticks: { - maxTicksLimit: 6, - maxRotation: 0, - min: xMin, - max: xMax, - fontFamily, - fontSize, - fontColor, - callback: (value, index) => (omitFirstTick && index === 0 ? '' : value) - } - } - ], - yAxes: [ - { - gridLines: { - color: gridColor - }, - ticks: { - fontFamily, - fontSize, - fontColor - } - } - ] - } - } - }) -} diff --git a/examples/playground/src/components/graph/graph-vm.ts b/examples/playground/src/components/graph/graph-vm.ts deleted file mode 100644 index a3c2f624..00000000 --- a/examples/playground/src/components/graph/graph-vm.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface Point { - x: number - y: number -} - -export type PlotStyle = 'normal' | 'wide' | 'dashed' - -export interface RefPlot { - points: Point[] - style: PlotStyle -} - -export interface GraphViewModel { - key: string - // refPlots: RefPlot[] - points: Point[] - xMin?: number - xMax?: number -} diff --git a/examples/playground/src/components/graph/graph.svelte b/examples/playground/src/components/graph/graph.svelte deleted file mode 100644 index 1311ae8c..00000000 --- a/examples/playground/src/components/graph/graph.svelte +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/playground/src/global.css b/examples/playground/src/global.css deleted file mode 100644 index b1dde997..00000000 --- a/examples/playground/src/global.css +++ /dev/null @@ -1,4 +0,0 @@ -body { - background-color: #222; - color: #f1f1f1; -} diff --git a/examples/playground/src/index.ts b/examples/playground/src/index.ts deleted file mode 100644 index 747dee67..00000000 --- a/examples/playground/src/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import App from './app.svelte' - -const app = new App({ - target: document.body -}) - -export default app diff --git a/examples/playground/src/types.d.ts b/examples/playground/src/types.d.ts deleted file mode 100644 index e680aea9..00000000 --- a/examples/playground/src/types.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// XXX: Workaround for lack of type declarations for the `compile` package -declare module '@sdeverywhere/compile' diff --git a/examples/playground/svelte.config.js b/examples/playground/svelte.config.js deleted file mode 100644 index 8638b5c5..00000000 --- a/examples/playground/svelte.config.js +++ /dev/null @@ -1,17 +0,0 @@ -import sveltePreprocess from 'svelte-preprocess' - -export default { - preprocess: sveltePreprocess({}), - onwarn: (warning, defaultHandler) => { - // TODO: We should resolve these warnings instead of ignoring them - if (warning.code === 'a11y-click-events-have-key-events') { - return - } - if (warning.code === 'a11y-no-noninteractive-tabindex') { - return - } - - // Handle all other warnings normally - defaultHandler(warning) - } -} diff --git a/examples/playground/tsconfig-base.json b/examples/playground/tsconfig-base.json deleted file mode 100644 index f4fcfd13..00000000 --- a/examples/playground/tsconfig-base.json +++ /dev/null @@ -1,16 +0,0 @@ -// This contains the TypeScript configuration that is shared between -// testing (`tsconfig-test.json`) and production builds (`tsconfig-build.json`). -{ - "extends": "../../tsconfig-common.json", - "compilerOptions": { - "outDir": "./dist", - "allowJs": true, - "resolveJsonModule": true, - "module": "esnext", - "target": "esnext", - "noImplicitAny": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "types": ["svelte", "vite/client"] - } -} diff --git a/examples/playground/tsconfig-build.json b/examples/playground/tsconfig-build.json deleted file mode 100644 index ce1ca9b9..00000000 --- a/examples/playground/tsconfig-build.json +++ /dev/null @@ -1,9 +0,0 @@ -// This contains the TypeScript configuration for production builds. -{ - "extends": "./tsconfig-base.json", - "compilerOptions": { - "skipLibCheck": true - }, - "include": ["src/**/*"], - "exclude": ["**/*.spec.ts"] -} diff --git a/examples/playground/tsconfig-test.json b/examples/playground/tsconfig-test.json deleted file mode 100644 index 7bd4cad8..00000000 --- a/examples/playground/tsconfig-test.json +++ /dev/null @@ -1,5 +0,0 @@ -// This contains the TypeScript configuration for testing. -{ - "extends": "./tsconfig-base.json", - "include": ["src/**/*"] -} diff --git a/examples/playground/tsconfig.json b/examples/playground/tsconfig.json deleted file mode 100644 index fc8b16a2..00000000 --- a/examples/playground/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -// This contains the TypeScript configuration for local development and testing. -// It is used as the TypeScript config for tools like VSCode that look for -// `tsconfig.json` by default. -{ - "extends": "./tsconfig-test.json" -} diff --git a/examples/playground/vite.config.js b/examples/playground/vite.config.js deleted file mode 100644 index 18f38d6c..00000000 --- a/examples/playground/vite.config.js +++ /dev/null @@ -1,86 +0,0 @@ -import { dirname, resolve as resolvePath } from 'path' -import { fileURLToPath } from 'url' - -import { defineConfig } from 'vite' -import { svelte } from '@sveltejs/vite-plugin-svelte' -import { nodePolyfills } from 'vite-plugin-node-polyfills' - -const production = process.env.NODE_ENV === 'production' - -// Note that Vite tries to inject `__dirname` but if we leave it undefined then -// Node will complain ("ERROR: __dirname is not defined in ES module scope") so -// we use our own special name here -const appDir = dirname(fileURLToPath(import.meta.url)) - -function localPackage(...subpath) { - return resolvePath(appDir, '..', '..', 'packages', ...subpath) -} - -export default defineConfig({ - // Don't clear the screen in dev mode so that we can see builder output - clearScreen: false, - - // Use `.` as the base directory (instead of the default `/`); this controls - // how the path to the js/css files are generated in `index.html` - base: '', - - // Load static files from `static` (instead of the default `public`) - publicDir: 'static', - - // Configure path aliases; these should match the corresponding lines in `tsconfig-base.json` - resolve: { - alias: { - '@sdeverywhere/compile': localPackage('compile', 'src'), - '@sdeverywhere/runtime': localPackage('runtime', 'src') - } - }, - - // Inject special values into the generated JS - define: { - // Set a flag to indicate that this is a production build - __PRODUCTION__: production - }, - - // Post-process CSS - css: { - postcss: { - minimize: true, - use: [['sass']] - } - }, - - build: { - // Write output files to `public` (instead of the default `dist`) - outDir: 'public', - - // Write js/css files to `public` (instead of the default `/assets`) - assetsDir: '', - - // TODO: Uncomment for debugging purposes - // minify: false, - - rollupOptions: { - output: { - // XXX: Prevent vite from creating a separate `vendor.js` file - manualChunks: undefined - } - } - }, - - plugins: [ - // Process Svelte files - svelte(), - - // XXX: Polyfill certain Node.js core modules until the compile package is - // updated to have a browser-friendly implementation - nodePolyfills() - ], - - server: { - // Run the dev server at `localhost:8081` by default - port: 8088, - - // Open the app in the browser by default - open: '/index.html' - } -})