Skip to content

Commit

Permalink
fix: vite gh pages deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
aotearoan committed Apr 24, 2023
1 parent 6d00315 commit 377f9e9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gh-pages-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require("fs");
try {
await execa("git", ["checkout", "--orphan", "gh-pages"]);
console.log("Building...");
await execa("npm", ["run", "build"]);
await execa("npm", ["run", "build-app"]);
await execa("git", ["--work-tree", "dist", "add", "--all"]);
await execa("git", ["--work-tree", "dist", "commit", "-m", "gh-pages"]);
console.log("Pushing to gh-pages...");
Expand Down
38 changes: 29 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aotearoan/neon",
"description": "Neon is a lightweight design library of Vue 3 components with minimal dependencies.",
"version": "9.2.7",
"version": "9.2.8",
"main": "./dist/neon.cjs.js",
"module": "dist/neon.es.js",
"types": "dist/neon.d.ts",
Expand All @@ -16,6 +16,7 @@
"scripts": {
"dev": "node doc-gen.js && genversion --es6 --semi ./version.ts && vite",
"build": "genversion --es6 --semi ./version.ts && vite build && vue-tsc --emitDeclarationOnly",
"build-app": "genversion --es6 --semi ./version.ts && vite --config vite.config.app.ts build",
"test": "genversion --es6 --semi ./version.ts && jest --no-cache",
"preview": "vite preview --port 4173",
"build-only": "vite build",
Expand Down Expand Up @@ -103,6 +104,7 @@
"typescript": "~4.7.4",
"vite": "^2.9.15",
"vite-plugin-css-injected-by-js": "^2.4.0",
"vite-plugin-environment": "^1.1.3",
"vite-svg-loader": "^4.0.0",
"vue-docgen-api": "^4.64.1",
"vue-prism-editor": "^2.0.0-alpha.2",
Expand Down
48 changes: 48 additions & 0 deletions vite.config.app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { fileURLToPath, URL } from 'url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import svgLoader from 'vite-svg-loader';
import { dependencies } from './package.json';
import EnvironmentPlugin from 'vite-plugin-environment';

const renderChunks = (deps: Record<string, string>) => {
let chunks: Record<string, any> = {};
Object.keys(deps).forEach((key) => {
if (['vue', 'vue-router'].includes(key)) return;
chunks[key] = [key];
});
return chunks;
};

export default defineConfig({
plugins: [vue(), svgLoader({ defaultImport: 'raw' }), EnvironmentPlugin('all')],
base: '/neon/',
server: {
host: '0.0.0.0',
port: 8081,
base: '/neon/',
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
vue$: 'vue/dist/vue.esm-bundler.js',
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['vue', 'vue-router'],
...renderChunks(dependencies),
},
entryFileNames: ({ name: fileName }) => {
return `${fileName}.js`;
},
globals: {
vue: 'Vue',
'vue-router': 'VueRouter',
},
},
},
},
});

0 comments on commit 377f9e9

Please sign in to comment.