Skip to content

Commit

Permalink
Merge pull request #3 from pichfl/build
Browse files Browse the repository at this point in the history
implement build
  • Loading branch information
pichfl authored Feb 2, 2024
2 parents 932dda8 + 09d35e3 commit 2d7cb1d
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions bin/auto-reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,44 @@

import path from 'node:path';
import { fileURLToPath } from 'url';
import { createServer } from 'vite';
import { createServer, build } from 'vite';
import { ViteEjsPlugin as viteEjsPlugin } from 'vite-plugin-ejs';
import { getTheme, getTitle } from '../lib/utils.js';

const __dirname = fileURLToPath(new URL('.', import.meta.url));
const argv = process.argv.slice(2);
const cwd = process.cwd();

getTheme();
const themeFolder = path.dirname(getTheme());
const config = {
configFile: false,
root: path.join(__dirname, '..', 'src'),
publicDir: path.join(cwd, 'public'),
server: {
port: 1337,
fs: {
allow: [themeFolder, '.']
}
},
plugins: [
viteEjsPlugin({
title: getTitle(),
}),
],
resolve: {
alias: {
slides: path.join(cwd, 'slides'),
'@theme': themeFolder,
},
},
build: {
outDir: path.join(cwd, 'dist')
}
};

async function start() {
const themeFolder = path.dirname(getTheme());
const server = await createServer({
configFile: false,
root: path.join(__dirname, '..', 'src'),
server: {
port: 1337,
fs: {
allow: [themeFolder, '.']
}
},
plugins: [
viteEjsPlugin({
title: getTitle(),
}),
],
resolve: {
alias: {
slides: path.join(cwd, 'slides'),
'@theme': themeFolder,
},
},
});

const server = await createServer(config);

server.watcher.add(path.join(cwd, 'slides'));

Expand All @@ -43,10 +48,8 @@ async function start() {
server.bindCLIShortcuts({ print: true });
}

async function build() {}

if (!argv[0] || argv[0] === 'start') {
start();
} else if (argv[0] === 'build') {
// Build for production
build(config)
}

0 comments on commit 2d7cb1d

Please sign in to comment.