oreonorth.blogg.se

Imageoptim with webpacker
Imageoptim with webpacker








imageoptim with webpacker
  1. #Imageoptim with webpacker code
  2. #Imageoptim with webpacker download

#Imageoptim with webpacker code

Sprockets is capable of pre-processing JS code by reading the extension from left to right.

imageoptim with webpacker

The syntax for requiring modules becomes bloated since you need to include the module via Sprockets in addition to JavaScript require. This works fine for traditional dependencies instantiated in the global context of the browser, but things get uglier if you need to pre-process your code or use CommonJS. The vendor libraries could then be included into the base application.js manifest file via Sprockets’ special directive processor, e.g.

#Imageoptim with webpacker download

Since node_modules wasn’t configured out of the box, if you wanted to include a vendor dependency, you would have to look for a Gem, or download the dependency manually and place it in the vendor/assets/javascripts directory.

imageoptim with webpacker

Path resolution specifically was hard to configure and there were some pretty weird ways of including dependencies. The Rails setup of frontend assets certainly worked, but coming from a Node setup, the architecture felt old and pieces didn’t seem like they came together very well. On top of that, the language that shipped with Rails was CoffeeScript, which was losing favor over the rising popularity of ES6 syntax. Instead, jQuery and a small number of popular JavaScript libraries wrapped by Gems are available. Specifically, Rails had its own asset packaging library called Sprockets, which was not pre-configured to resolve NPM dependencies. That meant it had strong opinions on how JavaScript should be handled. Rails, on the other hand, is commonly known for its preference for convention over configuration. That was before I knew anything about Rails conventions. Wanted ES6 on old browsers or a linter that checked your code as you worked? No problem, Webpack’s got your back. Having only worked with Node, it was easy to find a solution that was related to JavaScript. I was thrilled to hear Caviar used React! I could see myself building components with Promises and that cool new import syntax. ES6 was starting to gain more traction as compilers like Babel helped older browsers support the new syntax. NPM was the place to go to get any missing dependencies. jQuery was no longer the cool kid around the block. When I joined Caviar in 2016, I was fully bought into React and all the good stuff around building modular systems.










Imageoptim with webpacker