diff --git a/.github/workflows/frontend.yaml b/.github/workflows/frontend.yaml index f330dbd..378e8f5 100644 --- a/.github/workflows/frontend.yaml +++ b/.github/workflows/frontend.yaml @@ -18,4 +18,4 @@ jobs: run: | cd frontend npm install - npm run build \ No newline at end of file + npm run build --emptyOutDir \ No newline at end of file diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 32433fe..219cbed 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -30,7 +30,7 @@ jobs: run: | cd frontend npm install - npm run build + npm run build --emptyOutDir - name: Build Binary run: | python -m build diff --git a/frontend/README.md b/frontend/README.md index fdedbc6..83ea671 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -11,10 +11,12 @@ This project uses [Vite](https://vitejs.dev/) as the build tool. We followed [th To compile the frontend code, run: ```bash -npm run build +npm run build --emptyOutDir ``` -This will compile the frontend code into the `dist/static` directory. +This will compile the frontend code into the `../inventree_wireviz/static` directory. + +Note: The target directory is intentionally outside of hte frontend directory, so that the compiled files are correctly bundled into the python package install. ## Testing diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 8c725e3..4cc3cfc 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -13,8 +13,9 @@ export default defineConfig({ './src/WirevizPanel.tsx' ], output: { - entryFileNames: 'static/[name].js', - assetFileNames: 'static/assets/[name].[ext]', + dir: '../inventree_wireviz/static', + entryFileNames: '[name].js', + assetFileNames: 'assets/[name].[ext]', }, } } diff --git a/setup.py b/setup.py index b231422..d1f6a2e 100644 --- a/setup.py +++ b/setup.py @@ -1,26 +1,12 @@ # -*- coding: utf-8 -*- -import pathlib import setuptools -import shutil from inventree_wireviz.version import PLUGIN_VERSION with open('README.md', encoding='utf-8') as f: long_description = f.read() -# Copy the compiled frontend files into the 'static' directory -# Required for MANIFEST.in to work correctly -here = pathlib.Path(__file__).parent.absolute() - -# Copy the compiled frontend files into the 'static' directory -src_dir = here.joinpath('frontend/dist/static').resolve() -dst_dir = here.joinpath('inventree_wireviz/static').resolve() - -if src_dir.exists(): - print("Copying frontend files from", src_dir, "to", dst_dir) - shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True) - setuptools.setup( name="inventree-wireviz-plugin", version=PLUGIN_VERSION,