Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpacker 4.0 issue with Babel and CSS #78

Closed
db0sch opened this issue Mar 9, 2019 · 0 comments
Closed

Webpacker 4.0 issue with Babel and CSS #78

db0sch opened this issue Mar 9, 2019 · 0 comments
Assignees
Labels

Comments

@db0sch
Copy link
Contributor

db0sch commented Mar 9, 2019

I've been trying to install Mapbox on a new rails app generated by Le Wagon template.

First, by default, webpack won't extract CSS anymore. We need to enable it manually:

// config/webpacker.yml
[...]
# Extract and emit a css file
extract_css: true
[...]

Second, i encounter a weird bug on my browser console saying that variable _typeof was not defined. Map was not displayed. Only a grey area. Turns out that webpack was transpiling all node_modules packages through Babel, which causes an issue with mapbox-gl.

To avoid that, we need to add this line: environment.loaders.delete('nodeModules'); to the file config/webpack/environment.js.
It will bypass node_modules packages from the transpiler.
But if we want to bypass only a specific package, another gist of code is available there: rails/webpacker#1903 (comment)

Will do a PR when I have the time next week

@db0sch db0sch added the bug label Mar 9, 2019
@db0sch db0sch self-assigned this Mar 9, 2019
@db0sch db0sch closed this as completed Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant