From b00b1f7dd784c5afa7f734ea29385eebf8a5118f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Date: Wed, 23 Oct 2024 10:13:02 +0200 Subject: [PATCH] feat(packages/sui-svg): allow setting custom base path for svg icons build (vite) --- packages/sui-svg/bin/sui-svg-dist.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/sui-svg/bin/sui-svg-dist.js b/packages/sui-svg/bin/sui-svg-dist.js index 6c60bb972..07a73479e 100644 --- a/packages/sui-svg/bin/sui-svg-dist.js +++ b/packages/sui-svg/bin/sui-svg-dist.js @@ -3,15 +3,33 @@ import {resolve} from 'path' import {build} from 'vite' +import program from 'commander' const {pathname: root} = new URL('../src', import.meta.url) const outDir = resolve(process.cwd(), './public') const icons = resolve(process.cwd(), 'lib', '_demo.js') +const DEFAULT_BASE = '/' + console.log('[sui-svg] Preparing build with icons...') +program + .option('-b, --base [path]', 'Base public path') + .on('--help', () => { + console.log(' Examples:') + console.log('') + console.log(' $ sui-svg dist') + console.log(' $ sui-svg dist --base /my/abslotute/public/path') + console.log(' $ sui-svg dist --base https://my.full.url/public/path') + console.log('') + }) + .parse(process.argv) + +const {base = DEFAULT_BASE} = program.opts() + await build({ + base, root, optimizeDeps: { include: ['classnames', 'prop-types', 'react', 'react/jsx-runtime', 'react-dom']