Skip to content

Commit

Permalink
feat: define some globals (tajo#27)
Browse files Browse the repository at this point in the history
Co-authored-by: tajo <[email protected]>
  • Loading branch information
tajo and tajo authored Nov 4, 2021
1 parent e56d705 commit 73ca68e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/ladle/lib/cli/vite-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const getBaseViteConfig = (ladleConfig, configFolder, viteConfig) => {
configFile: false,
root: join(__dirname, "../app/"),
base: ladleConfig.build.baseUrl,
define: {
__BROWSER__: true,
__NODE__: false,
...(viteConfig.define ? viteConfig.define : {}),
},
cacheDir: join(process.cwd(), "node_modules/.vite"),
optimizeDeps: {
include: ["react", "react-dom"],
Expand Down
3 changes: 3 additions & 0 deletions packages/ladle/lib/cli/vite-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const bundler = async (config, configFolder) => {
*/
const viteConfig = getBaseViteConfig(config, configFolder, {
mode: "development",
define: {
__DEV__: true,
},
server: {
port: config.serve.port,
open: config.serve.open,
Expand Down
3 changes: 3 additions & 0 deletions packages/ladle/lib/cli/vite-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const viteProd = async (config, configFolder) => {
*/
const viteConfig = getBaseViteConfig(config, configFolder, {
mode: "production",
define: {
__DEV__: false,
},
build: {
outDir: path.join(process.cwd(), config.build.out),
sourcemap: config.build.sourcemap,
Expand Down

0 comments on commit 73ca68e

Please sign in to comment.