Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Sourcemaps don't work with simply renaming css later #39

Closed
kepta opened this issue Sep 17, 2018 · 3 comments
Closed

Sourcemaps don't work with simply renaming css later #39

kepta opened this issue Sep 17, 2018 · 3 comments

Comments

@kepta
Copy link
Contributor

kepta commented Sep 17, 2018

(Related #36)

With the recent implementation of hashing, the source map url in the generated css file doesn't get updated. This happens because we are providing a different output path.
As this will make any source map binded to provided path, simply calculating the hash and writting to new output would not work.

const writeOutput = root => {
return postcss(allPlugins)
.process(root, {
from: undefined,
to: output,
map: {
inline: sourceMap === SOURCE_MAP_INLINE
}
})
.then(result => {
if (hash) {
const fileHash = revHash(result.css);
output = output.replace(/\.css$/, `-${fileHash}.css`);
}
const promises = [promisify(fs.writeFile)(output, result.css)];
if (sourceMap === SOURCE_MAP_FILE) {
promises.push(promisify(fs.writeFile)(`${output}.map`, result.map));
}
return Promise.all(promises).then(() => output);
});
};

@kepta kepta changed the title Sourcemaps don't work with simply renaming css to css+hash Sourcemaps don't work with simply renaming css later Sep 17, 2018
@davidtheclark
Copy link
Contributor

@kepta
Copy link
Contributor Author

kepta commented Sep 17, 2018

Oh I see! Thanks @davidtheclark, this would do the job.

@kepta
Copy link
Contributor Author

kepta commented Nov 5, 2018

This is no longer valid as we are using Webpack for css loading.

@kepta kepta closed this as completed Nov 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants