"path"
"strings"
+ "github.com/spf13/cast"
+
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugolib/filesystems"
"github.com/gohugoio/hugo/media"
// External dependencies, e.g. "react".
Externals []string `hash:"set"`
+ // User defined symbols.
+ Defines map[string]interface{}
+
// What to use instead of React.createElement.
JSXFactory string
Externals []string `hash:"set"`
+ Defines map[string]string
+
// These are currently not exposed in the public Options struct,
// but added here to make the options hash as stable as possible for
// whenever we do.
- Defines map[string]string
TSConfig string
}
return
}
err = mapstructure.WeakDecode(m, &opts)
+ err = mapstructure.WeakDecode(m, &opts)
if opts.TargetPath != "" {
opts.TargetPath = helpers.ToSlashTrimLeading(opts.TargetPath)
if target == "" {
target = defaultTarget
}
+ var defines map[string]string
+ if opts.Defines != nil {
+ defines = cast.ToStringMapString(opts.Defines)
+ }
return internalOptions{
TargetPath: opts.TargetPath,
Minify: opts.Minify,
Target: target,
Externals: opts.Externals,
+ Defines: defines,
JSXFactory: opts.JSXFactory,
JSXFragment: opts.JSXFragment,
}
JSXFactory: "v3",
JSXFragment: "v4",
Externals: []string{"react"},
+ Defines: map[string]interface{}{"process.env.NODE_ENV": "production"},
Minify: true,
}
JSXFactory: "v3",
JSXFragment: "v4",
Externals: []string{"react"},
- Defines: nil,
+ Defines: map[string]string{"process.env.NODE_ENV": "production"},
TSConfig: "",
})