Skip to content

Commit

Permalink
feat: micro optimize storefront build execution
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Apr 17, 2024
1 parent 3ce838d commit 4a20878
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions extension/asset_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func BuildAssetsForExtensions(ctx context.Context, sources []asset.Source, asset
}

envList := []string{
"NODE_ENV=production",
fmt.Sprintf("PROJECT_ROOT=%s", shopwareRoot),
fmt.Sprintf("STOREFRONT_ROOT=%s", storefrontRoot),
}
Expand All @@ -219,11 +220,16 @@ func BuildAssetsForExtensions(ctx context.Context, sources []asset.Source, asset
envList = append(envList, fmt.Sprintf("BROWSERSLIST=%s", assetConfig.Browserslist))
}

err = npmRunBuild(
storefrontRoot,
"production",
envList,
)
nodeWebpackCmd := exec.Command("node", "node_modules/.bin/webpack", "--config", "webpack.config.js")
nodeWebpackCmd.Dir = storefrontRoot
nodeWebpackCmd.Env = os.Environ()
nodeWebpackCmd.Env = append(nodeWebpackCmd.Env, envList...)
nodeWebpackCmd.Stdout = os.Stdout
nodeWebpackCmd.Stderr = os.Stderr

if err := nodeWebpackCmd.Run(); err != nil {
return err
}

if assetConfig.CleanupNodeModules {
defer deletePaths(ctx, path.Join(storefrontRoot, "node_modules"))
Expand Down

0 comments on commit 4a20878

Please sign in to comment.