caiogondim / webpack-conditional-loader

C conditionals directive for JavaScript
https://npm.im/webpack-conditional-loader
MIT License
110 stars 25 forks source link

Fix on Windows #6

Open Mirantus opened 6 years ago

Mirantus commented 6 years ago

It's doesnt work on Windows when files have file encodings with '\n'. os.EOL returns '\n\r' so we have array sourceByLine as one string instead of multivalues. Then commentCodeInsideBlocks can't find this big string in truthyBlocks and nothing do.

bbert commented 6 years ago

I would suggest to use the regular expression /[\r\n]+/g to detect end of lines:

const sourceByLine = source.split(/[\r\n]+/g)