css-modules / css-modulesify

A browserify plugin to load CSS Modules
MIT License
403 stars 47 forks source link

Doesn't work with postcss-url copy #99

Closed saiichihashimoto closed 1 year ago

saiichihashimoto commented 8 years ago

The only way I can get url(...) to work with css-modulesify is using the suggestion from https://github.com/css-modules/css-modulesify/issues/33#issuecomment-133268106 to copy all the assets over beforehand. However, plugins like postcss-url exist for the specific reason to decide whether or not to copy these assets.

I'm unable to use postcss-url with copy or postcss-copy-assets (or any plugin) to copy the assets for me. The error (as I see it) is that postcss isn't being given from and to values that make any sense. I'm receiving this error, which seems to back that up: https://github.com/postcss/postcss-url/blob/a9d1d4307b061210b1e051d1c2e9c481ca6afbf5/index.js#L285

kelseyll commented 8 years ago

⬆️ ⬆️ ⬆️

joshwnj commented 8 years ago

Thanks for reporting @saiichihashimoto. Do you have an example repo or test case that we can use to reproduce this error and investigate more?

saiichihashimoto commented 8 years ago

This is simplified from a private repo, so hopefully there's no typos from modifying it :-)

Build step: mkdir -p dist/js dist/css && browserify ./client -o dist/js/script.js --debug --verbose --extension=.jsx --extension=.css -p [ css-modulesify -o dist/css/style.css --after postcss-nested --after cssnano --after postcss-font-magician --after postcss-url --after postcss-cachebuster --cssnano.postcssDiscardUnused.disable true --cssnano.postcssDiscardDuplicates.disable true --postcss-url.url inline --postcss-url.fallback copy ]

Error Message:

file unreachable or not exists /components/Global/fonts/Menlo-Regular.ttf
file unreachable or not exists /components/Global/fonts/abnzAgzJQcZknTtAKPIM.eot
file unreachable or not exists /components/Global/fonts/abnzAgzJQcZknTtAKPIM.eot
file unreachable or not exists /components/Global/fonts/abnzAgzJQcZknTtAKPIM.woff2
file unreachable or not exists /components/Global/fonts/abnzAgzJQcZknTtAKPIM.woff
file unreachable or not exists /components/Global/fonts/abnzAgzJQcZknTtAKPIM.ttf
file unreachable or not exists /components/Global/fonts/abnzAgzJQcZknTtAKPIM.svg
file unreachable or not exists /components/Global/fonts/nocturno.woff

../../../../components/Global/Global.css
21:3    ⚠  Can't read file '/components/Global/fonts/Menlo-Regular.ttf', ignoring [postcss-url]
26:3    ⚠  Can't read file '/components/Global/fonts/abnzAgzJQcZknTtAKPIM.eot', ignoring [postcss-url]
27:3    ⚠  Option `to` of postcss is required, ignoring [postcss-url]
27:3    ⚠  Can't read file '/components/Global/fonts/abnzAgzJQcZknTtAKPIM.woff2', ignoring [postcss-url]
27:3    ⚠  Can't read file '/components/Global/fonts/abnzAgzJQcZknTtAKPIM.woff', ignoring [postcss-url]
27:3    ⚠  Can't read file '/components/Global/fonts/abnzAgzJQcZknTtAKPIM.ttf', ignoring [postcss-url]
27:3    ⚠  Option `to` of postcss is required, ignoring [postcss-url]
36:3    ⚠  Can't read file '/components/Global/fonts/nocturno.woff', ignoring [postcss-url]

file unreachable or not exists /components/LandingPage/leafflat.svg
file unreachable or not exists /components/LandingPage/people3.png
file unreachable or not exists /components/LandingPage/x.svg

../../../../components/LandingPage/LandingPage.css
23:5    ⚠  Can't read file '/components/LandingPage/leafflat.svg', ignoring [postcss-url]
187:5   ⚠  Can't read file '/components/LandingPage/people3.png', ignoring [postcss-url]
310:5   ⚠  Can't read file '/components/LandingPage/x.svg', ignoring [postcss-url]
joshwnj commented 8 years ago

Thanks @saiichihashimoto - this is something we definitely want to get working, so will take a look as I have opportunity :)