Skip to content

Commit 373425a

Browse files
authored
Prevent non-reproducible Sass/CSS builds. (#76098)
This adds `sourceMap: false` to `sassPlugin` calls to prevent scenarios where CSS builds are inconsistent and non-reproducible due to the fact that `esbuild-sass-plugin` uses absolute paths when creating the `sourceMappingURLs` included in generated CSS. The `wp-build` package creates a hash of each CSS file to serve as a value of the `data-wp-hash` attribute. While `/*# sourceMappingURL=... */` is stripped out of the built CSS files, this is handled by `postcss` after the hash is generated from the file's contents. Instead of relying on `postcss` to strip source maps out at the end, `sourceMap: false` ensures it's never included. This results in consistent hash generation when the file contents are unchanged regardless of where the repository is cloned or which operating system is being used.
1 parent 535405a commit 373425a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/wp-build/lib/build.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ function createStyleBundlingPlugins( workingDir ) {
228228
// Handle CSS modules (.module.css and .module.scss)
229229
sassPlugin( {
230230
embedded: true,
231+
sourceMap: false,
231232
filter: /\.module\.(css|scss)$/,
232233
transform: compileInlineStyle( { cssModules: true } ),
233234
type: inlineStyle,
@@ -237,6 +238,7 @@ function createStyleBundlingPlugins( workingDir ) {
237238
// Note: .module.css and .module.scss already handled by plugin above
238239
sassPlugin( {
239240
embedded: true,
241+
sourceMap: false,
240242
filter: /\.(css|scss)$/,
241243
transform: compileInlineStyle(),
242244
type: inlineStyle,

0 commit comments

Comments
 (0)