@@ -25,7 +25,7 @@ const BuildCache = require('./cache.js');
25
25
*/
26
26
const buildCssModulesJs = async ( { fullPath, options, build } ) => {
27
27
const cssFileName = path . basename ( fullPath ) ; // e.g. xxx.module.css?esbuild-css-modules-plugin-building
28
- const { buildId } = build . context ;
28
+ const { buildId, relative } = build . context ;
29
29
const resolveDir = path . dirname ( fullPath ) ;
30
30
const classPrefix = path . basename ( fullPath , path . extname ( fullPath ) ) . replace ( / \. / g, '-' ) + '__' ;
31
31
const originCss = await readFile ( fullPath ) ;
@@ -34,7 +34,7 @@ const buildCssModulesJs = async ({ fullPath, options, build }) => {
34
34
* @type {import('@parcel/css').BundleOptions }
35
35
*/
36
36
const bundleConfig = {
37
- filename : fullPath ,
37
+ filename : relative ( fullPath ) , // use relative path to keep hash stable in different machines
38
38
code : originCss ,
39
39
minify : false ,
40
40
sourceMap : true ,
@@ -318,7 +318,9 @@ const onEnd = async (build, options, result) => {
318
318
const r = ( p ) => path . relative ( absOutdir , p ) . split ( path . sep ) . join ( path . posix . sep ) ;
319
319
const imports = `import "./${ r ( entryPath ) } ";\nexport * from "./${ r ( entryPath ) } ";` ;
320
320
if ( sourcemap === 'external' ) {
321
- await appendFile ( entryPath , `\n//# sourceMappingURL=${ r ( entryPath ) } .map` , { encoding : 'utf8' } ) ;
321
+ await appendFile ( entryPath , `\n//# sourceMappingURL=${ r ( entryPath ) } .map` , {
322
+ encoding : 'utf8'
323
+ } ) ;
322
324
} else if ( publicPath && sourcemap ) {
323
325
const fixedPublicPath = publicPath . endsWith ( '/' ) ? publicPath : publicPath + '/' ;
324
326
const entryContent = await readFile ( entryPath , { encoding : 'utf8' } ) ;
0 commit comments