Rails 5/6: How to include JS functions with webpacker?

For instructions on moving from the old asset pipeline to the new webpacker way of doing things, you can see here: https://www.calleerlandsson.com/replacing-sprockets-with-webpacker-for-javascript-in-rails-5-2/ This is a howto for moving from the asset pipeline to webpacker in Rails 5.2, and it gives you an idea of how things are different in Rails 6 now that webpacker is … Read more

How to add jquery third party plugin in rails 6 webpacker

run below command to add jQuery. $ yarn add jquery Add below code in config/webpack/environment.js const webpack = require(‘webpack’) environment.plugins.prepend(‘Provide’, new webpack.ProvidePlugin({ $: ‘jquery/src/jquery’, jQuery: ‘jquery/src/jquery’ }) ) Require jquery in application.js file. require(‘jquery’) No more need to add jquery-rails gem!

Rails: Webpacker 4.2 can’t find application in /app/public/packs/manifest.json heroku

It looks like there’s no application.css in your manifest.json which means you might not be importing any css from within your Webpack javascript files. If that’s all true, then you can fix the error in production by one of the following: Quick (temporary) fix: Add extract_css: false to your production block in config/webpacker.yml (which would … Read more

How to import and use image in a Vue single file component?

As simple as: <template> <div id=”app”> <img src=”./assets/logo.png”> </div> </template> <script> export default { } </script> <style lang=”css”> </style> Taken from the project generated by vue cli. If you want to use your image as a module, do not forget to bind data to your Vuejs component: <template> <div id=”app”> <img :src=”image”/> </div> </template> <script> … Read more