Skip to content

Commit

Permalink
[Build] Define process.env.NODE_ENV as part of the vite build
Browse files Browse the repository at this point in the history
This allows us to use Lux's IIFE distribution in <script src=""> without
the error: "process is not defined"

See environments variable section under https://vitejs.dev/guide/build.html#library-mode

Co-authored-by: Christina Chortaria <[email protected]>
  • Loading branch information
sandbergja and christinach committed Aug 7, 2024
1 parent 9c1cfab commit 42c3e6b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
7 changes: 0 additions & 7 deletions docs/adding_lux.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ If you can't use an import map and have to use `<script src>` then from cdn use
Add the following `<script>` tags after the `<head>` tag:
```
<script>
window.process = {
env: {
NODE_ENV: 'production'
}
};
</script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://unpkg.com/[email protected]/dist/lux-styleguidist.iife.js"></script>
```
Expand Down
1 change: 1 addition & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default defineConfig({
hook: "writeBundle",
}),
],
define: { "process.env.NODE_ENV": '"production"' },
build: {
lib: {
// Could also be a dictionary or array of multiple entry points
Expand Down

0 comments on commit 42c3e6b

Please sign in to comment.