blakeembrey / free-style

Make CSS easier and more maintainable by using JavaScript
MIT License
707 stars 29 forks source link

Fix "process is not defined" using rollup #54

Closed porsager closed 7 years ago

porsager commented 7 years ago

When using free-style with rollup (and probably other bundlers that doesn't expose a process object) it fails with "process is not defined". Check first to see if process is undefined to make sure free-style works out of the box with those bundlers.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.8%) to 97.967% when pulling ea5f14e8e5254b44bb406a9c3fdd4ac28f575f3d on porsager:patch-1 into 80253357ba0ce1cba5709b641e8aeca73e0f0cc6 on blakeembrey:master.

blakeembrey commented 7 years ago

Looks good. Is there a better way to "detect" debug mode in rollup?

blakeembrey commented 7 years ago

Released with https://github.com/blakeembrey/free-style/releases/tag/v2.3.1 ❤️

porsager commented 7 years ago

Cool.. Thanks a lot for the quick reaction ;) To set debug with rollup in this case i would probably just use "banner" to add the process global to the window like:

rollup({
  ...
}).then(bundle => {
  bundle.generate({
    banner: '{ window.process = { env: { NODE_ENV: "development" } } };'
  })
})