mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Add "hugo mod npm pack"
This commit also introduces a convention where these common JS config files, including `package.hugo.json`, gets mounted into: ``` assets/_jsconfig ´`` These files mapped to their real filename will be added to the environment when running PostCSS, Babel etc., so you can do `process.env.HUGO_FILE_TAILWIND_CONFIG_JS` to resolve the real filename. But do note that `assets` is a composite/union filesystem, so if your config file is not meant to be overridden, name them something specific. This commit also adds adds `workDir/node_modules` to `NODE_PATH` and `HUGO_WORKDIR` to the env when running the JS tools above. Fixes #7644 Fixes #7656 Fixes #7675
This commit is contained in:
@@ -170,17 +170,11 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC
|
||||
|
||||
// We need an abolute filename to the config file.
|
||||
if !filepath.IsAbs(configFile) {
|
||||
// We resolve this against the virtual Work filesystem, to allow
|
||||
// this config file to live in one of the themes if needed.
|
||||
fi, err := t.rs.BaseFs.Work.Stat(configFile)
|
||||
if err != nil {
|
||||
if t.options.Config != "" {
|
||||
// Only fail if the user specificed config file is not found.
|
||||
return errors.Wrapf(err, "postcss config %q not found:", configFile)
|
||||
}
|
||||
configFile = ""
|
||||
} else {
|
||||
configFile = fi.(hugofs.FileMetaInfo).Meta().Filename()
|
||||
configFile = t.rs.BaseFs.ResolveJSConfigFile(configFile)
|
||||
if configFile == "" && t.options.Config != "" {
|
||||
// Only fail if the user specificed config file is not found.
|
||||
return errors.Errorf("postcss config %q not found:", configFile)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +196,8 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC
|
||||
|
||||
cmd.Stdout = ctx.To
|
||||
cmd.Stderr = io.MultiWriter(infoW, &errBuf)
|
||||
cmd.Env = hugo.GetExecEnviron(t.rs.Cfg)
|
||||
|
||||
cmd.Env = hugo.GetExecEnviron(t.rs.WorkingDir, t.rs.Cfg, t.rs.BaseFs.Assets.Fs)
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user