To prepare a production release for both NPM and PyPI, follow these steps:
- Build JS: Run
npm run build. - Create Tarball: Run
python setup.py sdist to generate a distribution tarball in the dist/ folder. - Verify: Install the generated tarball in a clean environment using
pip install <tarball-name>.tar.gz. - Publish to PyPI: Use
twine upload dist/*. - Publish to NPM: Use
npm publish.
Important Note on CDN usage:
Publishing to NPM makes the JavaScript bundles available on the unpkg CDN. By default, Dash servers components from the remote unpkg CDN. If you do not publish to NPM, you must set the serve_locally flag to True in your Dash application to ensure the components load correctly.
# 1. Build code
$ npm run build
# 2. Create Python tarball
$ python setup.py sdist
# 3. Test tarball (in a new env)
$ pip install dash-html-components-<version>.tar.gz
# 4. Publish to PyPI
$ twine upload dist/*
# 5. Publish to NPM
$ npm publish