Skip to content

Commit

Permalink
do not use process.env.NODE_ENV to detect production environment — …
Browse files Browse the repository at this point in the history
…instead use import condition
  • Loading branch information
sastan committed Dec 15, 2022
1 parent 61e38e3 commit e9d8dcc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 59 deletions.
8 changes: 8 additions & 0 deletions .changeset/purple-horses-study.md
@@ -0,0 +1,8 @@
---
'gatsby-plugin-twind': minor
'@twind/with-next': minor
'@twind/with-remix': minor
'@twind/with-sveltekit': minor
---

do not use `process.env.NODE_ENV` to detect production environment — instead use import condition
2 changes: 1 addition & 1 deletion examples/with-next/next.config.js
Expand Up @@ -8,7 +8,7 @@ const withTM = require('next-transpile-modules')
* @type {import('next').NextConfig}
**/
module.exports = withPlugins(
[withTM(['twind', '@twind/preset-autoprefix', '@twind/preset-tailwind', '@twind/with-next'])],
[withTM(['@twind/core', '@twind/preset-autoprefix', '@twind/preset-tailwind', '@twind/with-next'])],
{
/* regular next.js config options here */
reactStrictMode: true,
Expand Down
6 changes: 3 additions & 3 deletions examples/with-remix/tsconfig.json
Expand Up @@ -13,8 +13,8 @@
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true
"noEmit": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true
}
}
2 changes: 1 addition & 1 deletion packages/with-gatsby/src/install-twind.ts
Expand Up @@ -3,5 +3,5 @@ import { install as install$ } from '@twind/core'
import config from 'gatsby-plugin-twind/config'

export default function install() {
return install$(config, process.env.NODE_ENV == 'production')
return install$(config)
}
5 changes: 4 additions & 1 deletion packages/with-next/src/app.ts
Expand Up @@ -4,6 +4,7 @@ import type { TwindConfig, TwindUserConfig } from '@twind/core'

import { createElement } from 'react'
import { install as install$ } from '@twind/core'
import { PROD } from 'distilt/env'

export default install

Expand All @@ -14,13 +15,15 @@ function install(
function install<Props, Component>(
config: TwindConfig<any> | TwindUserConfig<any>,
AppComponent: React.JSXElementConstructor<Props> & Component,
isProduction?: boolean,
): Component

function install<Props, Component>(
config: TwindConfig | TwindUserConfig,
AppComponent: React.JSXElementConstructor<Props> & Component = TwindApp as any,
isProduction = PROD,
): Component {
install$(config as TwindUserConfig, process.env.NODE_ENV == 'production')
install$(config as TwindUserConfig, isProduction)

return AppComponent
}
Expand Down
25 changes: 1 addition & 24 deletions packages/with-remix/src/index.ts
@@ -1,24 +1 @@
import type {
Twind,
BaseTheme,
TwindConfig,
TwindUserConfig,
Preset,
ExtractThemes,
} from '@twind/core'

import { install as install$ } from '@twind/core'

export default install

function install<Theme extends BaseTheme = BaseTheme>(
config: TwindConfig<Theme>,
): Twind<Theme & BaseTheme>

function install<Theme = BaseTheme, Presets extends Preset<any>[] = Preset[]>(
config: TwindUserConfig<Theme, Presets>,
): Twind<BaseTheme & ExtractThemes<Theme, Presets>>

function install(config: TwindConfig | TwindUserConfig): Twind {
return install$(config as TwindConfig, process.env.NODE_ENV == 'production')
}
export { install as default } from '@twind/core'
30 changes: 1 addition & 29 deletions packages/with-sveltekit/src/index.ts
@@ -1,29 +1 @@
import type {
Twind,
BaseTheme,
TwindConfig,
TwindUserConfig,
Preset,
ExtractThemes,
} from '@twind/core'

import { install as install$ } from '@twind/core'

export default install

function install<Theme extends BaseTheme = BaseTheme>(
config: TwindConfig<Theme>,
isProduction?: boolean,
): Twind<Theme & BaseTheme>

function install<Theme = BaseTheme, Presets extends Preset<any>[] = Preset[]>(
config: TwindUserConfig<Theme, Presets>,
isProduction?: boolean,
): Twind<BaseTheme & ExtractThemes<Theme, Presets>>

function install(
config: TwindConfig | TwindUserConfig,
isProduction = process.env.NODE_ENV == 'production',
): Twind {
return install$(config as TwindConfig, isProduction)
}
export { install as default } from '@twind/core'

0 comments on commit e9d8dcc

Please sign in to comment.