Skip to content

Commit

Permalink
Fix npm build output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Sep 30, 2024
1 parent 683bdfc commit ff5734a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
run: |
cd frontend
npm install
npm run build
npm run build --emptyOutDir
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
cd frontend
npm install
npm run build
npm run build --emptyOutDir
- name: Build Binary
run: |
python -m build
Expand Down
6 changes: 4 additions & 2 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]',
},
}
}
Expand Down
14 changes: 0 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit ff5734a

Please sign in to comment.