From b0a53645e652967c24952ffa8bc858e1d09f4e73 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 3 May 2024 18:51:22 +0000 Subject: [PATCH] Switch from snowpack to vite for frontend tooling Closes: #3 --- package.json | 25 +++++++++++++------------ snowpack.config.mjs | 33 --------------------------------- vite.config.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 45 deletions(-) delete mode 100644 snowpack.config.mjs create mode 100644 vite.config.js diff --git a/package.json b/package.json index 2cb6641..4cd71ad 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,23 @@ { - "type": "module", + "name": "owl-vite", + "version": "0.0.0", "scripts": { - "start": "NODE_OPTIONS='--experimental-json-modules' snowpack dev", - "build": "NODE_OPTIONS='--experimental-json-modules' snowpack build", - "test": "echo \"This template does not include a test runner by default.\" && exit 1" + "dev": "vite", + "build": "vite build", + "preview": "vite preview" }, "dependencies": { "@popperjs/core": "^2.11.0", + "bootstrap": "^5.3.2", "fork-awesome": "^1.2.0", - "leaflet": "^1.8.0", - "leaflet-extra-markers": "^1.2.1", - "redaxios": "^0.4.1", - "vue": "^3.2.26" + "leaflet": "^1.9.4", + "leaflet-extra-markers": "^1.2.2", + "redaxios": "^0.5.1", + "vue": "^3.3.7" }, "devDependencies": { - "@snowpack/plugin-dotenv": "^2.1.0", - "@snowpack/plugin-vue": "^2.4.0", - "snowpack": "^3.3.7", - "snowpack-plugin-cdn-import": "^1.0.0" + "@vitejs/plugin-vue": "^4.4.0", + "rollup-plugin-esm-import-to-url": "^2.1.0", + "vite": "^4.5.0" } } diff --git a/snowpack.config.mjs b/snowpack.config.mjs deleted file mode 100644 index 167d5bb..0000000 --- a/snowpack.config.mjs +++ /dev/null @@ -1,33 +0,0 @@ -/** @type {import("snowpack").SnowpackUserConfig } */ -export default { - mount: { - public: {url: '/', static: true}, - frontend: {url: '/dist'}, - }, - plugins: [ - '@snowpack/plugin-vue', - '@snowpack/plugin-dotenv', - ['snowpack-plugin-cdn-import', { - dependencies: pkg.dependencies, - enableInDevMode: true, - baseUrl: 'https://unpkg.com', - }] - ], - routes: [ - /* Enable an SPA Fallback in development: */ - // {"match": "routes", "src": ".*", "dest": "/index.html"}, - ], - optimize: { - /* Example: Bundle your final build: */ - // "bundle": true, - }, - packageOptions: { - /* ... */ - }, - devOptions: { - /* ... */ - }, - buildOptions: { - /* ... */ - }, -}; diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..cee5e19 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,29 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import path from 'path' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue()], + define: { 'process.env.NODE_ENV': '"production"' }, + build: { + target: 'esnext', + lib: { + entry: path.resolve(__dirname, 'src/main.js'), + name: 'OWL', + fileName: (format) => `owl.${format}.js` + }, + }, + /* rollupOptions: { + external: ['vue', 'leaflet'], + output: { + // Provide global variables to use in the UMD build + // for externalized deps + globals: { + vue: 'Vue', + leaflet: 'L', + } + } + }, */ + // }, +})