Skip to content

Commit 6eb3386

Browse files
committed
Fix options pass empty
1 parent 458b215 commit 6eb3386

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ function overrideCracoConfig({ cracoConfig, pluginOptions = {} }) {
2929
loadEnvironment(localPath)
3030
loadEnvironment(basePath)
3131

32-
const plugin = new webpack.EnvironmentPlugin(pluginOptions.variables)
33-
34-
if (cracoConfig.webpack) {
35-
if (cracoConfig.webpack.plugins) {
36-
const webpackPlugins = cracoConfig.webpack.plugins
37-
;(webpackPlugins.add || webpackPlugins).push(plugin)
32+
if (pluginOptions.variables) {
33+
const plugin = new webpack.EnvironmentPlugin(pluginOptions.variables)
34+
35+
if (cracoConfig.webpack) {
36+
if (cracoConfig.webpack.plugins) {
37+
const webpackPlugins = cracoConfig.webpack.plugins
38+
;(webpackPlugins.add || webpackPlugins).push(plugin)
39+
} else {
40+
cracoConfig.webpack.plugins = [plugin]
41+
}
3842
} else {
39-
cracoConfig.webpack.plugins = [plugin]
40-
}
41-
} else {
42-
cracoConfig.webpack = {
43-
plugins: [plugin]
43+
cracoConfig.webpack = {
44+
plugins: [plugin]
45+
}
4446
}
4547
}
4648

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "craco-plugin-env",
33
"description": "An environment plugin for craco",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"main": "index.js",
66
"repository": "https://github.com/ponjs/craco-plugin-env.git",
77
"keywords": [

0 commit comments

Comments
 (0)