Skip to content

Commit

Permalink
Fix options pass empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ponjs committed Dec 13, 2021
1 parent 458b215 commit 6eb3386
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ function overrideCracoConfig({ cracoConfig, pluginOptions = {} }) {
loadEnvironment(localPath)
loadEnvironment(basePath)

const plugin = new webpack.EnvironmentPlugin(pluginOptions.variables)

if (cracoConfig.webpack) {
if (cracoConfig.webpack.plugins) {
const webpackPlugins = cracoConfig.webpack.plugins
;(webpackPlugins.add || webpackPlugins).push(plugin)
if (pluginOptions.variables) {
const plugin = new webpack.EnvironmentPlugin(pluginOptions.variables)

if (cracoConfig.webpack) {
if (cracoConfig.webpack.plugins) {
const webpackPlugins = cracoConfig.webpack.plugins
;(webpackPlugins.add || webpackPlugins).push(plugin)
} else {
cracoConfig.webpack.plugins = [plugin]
}
} else {
cracoConfig.webpack.plugins = [plugin]
}
} else {
cracoConfig.webpack = {
plugins: [plugin]
cracoConfig.webpack = {
plugins: [plugin]
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "craco-plugin-env",
"description": "An environment plugin for craco",
"version": "1.0.1",
"version": "1.0.2",
"main": "index.js",
"repository": "https://github.com/ponjs/craco-plugin-env.git",
"keywords": [
Expand Down

0 comments on commit 6eb3386

Please sign in to comment.