Switch from snowpack to vite for frontend tooling

Closes: #3
This commit is contained in:
Edward Betts 2024-05-03 18:51:22 +00:00
parent 030e0af610
commit b0a53645e6
3 changed files with 42 additions and 45 deletions

View file

@ -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"
}
}

View file

@ -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: {
/* ... */
},
};

29
vite.config.js Normal file
View file

@ -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',
}
}
}, */
// },
})