webpacker

Rails 6: How to add jquery-ui through webpacker?

我的梦境 提交于 2020-01-11 09:23:07
问题 I'm currently trying to implement a datepicker into my application, the problem is that there is no documentation on how to add the jquery-ui-rails gem through webpacker. Probably there is another way to add gems or another gem that would fit my needs? 回答1: You no longer need to add javascript libraries as gems (which are managed by the bundler). Instead, you add them with yarn and they are managed by webpack (which is enabled by adding the webpacker gem to the Gemfile). The following steps

window.autoInit in Rails using material-components-web and webpacker

可紊 提交于 2020-01-06 07:01:44
问题 I'm using Rails 5.1.4 with the code below. I have confirmed that the material.js file is being processed and the material-components-web module is downloaded and discovered. Why is mdc undefined when calling window.mdc.autoInit() ? // app/javascript/packs/material.js import 'material-components-web' // app/views/layouts/application.html.eeb <html> <head> <%= javascript_pack_tag 'material' %> </head> <body> <script>window.mdc.autoInit();</script> </body> </html> I have tried importing

How to use Webpacker for React on an existing Rails 5.0.2 application?

醉酒当歌 提交于 2020-01-05 07:18:03
问题 I have an existing rails 5.0.2 app and want to add a React (with Redux) application to a few of the pages Found webpacker gem but am experiencing this problem when setting up the webpacker install for React : $ bundle exec rails webpacker:install:react Configuration config/webpacker.yml file not found. Make sure webpacker:install is run successfully before running dependent tasks This is how I installed the gem in the Gemfile: gem 'webpacker', '~> 3.2' This is how I invoked the install: $

How to use Webpacker for React on an existing Rails 5.0.2 application?

岁酱吖の 提交于 2020-01-05 07:17:31
问题 I have an existing rails 5.0.2 app and want to add a React (with Redux) application to a few of the pages Found webpacker gem but am experiencing this problem when setting up the webpacker install for React : $ bundle exec rails webpacker:install:react Configuration config/webpacker.yml file not found. Make sure webpacker:install is run successfully before running dependent tasks This is how I installed the gem in the Gemfile: gem 'webpacker', '~> 3.2' This is how I invoked the install: $

Installing https://github.com/twbs/bootstrap-rubygem on rails 6 alpha

孤街浪徒 提交于 2020-01-04 03:17:31
问题 How do you install the bootstrap gem (https://github.com/twbs/bootstrap-rubygem) on rails 6? The bootstrap README asks us to add things to application.js but rails 6 doesn't seem to have an application.js in the usual place. [ Rails 6.0.0.alpha ] bundle exec rails new noname --edge --database=postgresql --webpacker=react 回答1: If you use webpacker, you may want to use the npm package of bootstrap yarn add bootstrap@4.0.0 popper.js and # app/javascript/packs/application.js import 'bootstrap

Bootstrap JS functions not loading in Rails 6/Webpacker

ぐ巨炮叔叔 提交于 2019-12-25 00:28:14
问题 Climbing the learning curve with Webpacker and Rails 6. I've installed Boostrap 4 using Yarn and Webpacker. When I try play with Bootstrap components in a browser's JS console then I get: TypeError: $.fn.button is undefined . If I remove the Yarn installation add a Bootstrap CDN link in the head of the HTML (the old way) everything works fine. When I remove the CDN links and revert to using Webpacker I get back to the error above. Here is my Webpacker setup: // package.json { "name": "depot",

How to test a Webpack bundle that has external dependencies?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 20:12:07
问题 I'm new to Webpacker and Rails in general. I recently moved to using Webpacker to bundle React components. Since part of the application still uses the asset pipeline, some dependencies are still stored in vendor/assets/javascript , and accessible as globals. The Webpack bundle declares those dependencies as external, and when serving the app, everything works great, as Rails serves the dependencies, which are then picked up by the bundle. Now I want to start testing the bundle using

window is not defined in server side render window.webpackJsonp

大城市里の小女人 提交于 2019-12-24 06:47:50
问题 I'm attempting to upgrade a Rails/Webpacker/ReactOnRails application to webpack 4. I have included a call to environment.splitChunks . That is placing this code: window.webpackJsonp=window.webpackJsonp||[]).push([[11],....... in my bundle. Since this is my server side bundle, window does not exist. Is there a way to completely exclude this bundle from having webpackJsonp added? I have tried these two configurations: environment.splitChunks(); and environment.splitChunks(config => Object

Getting Jquery and Bootstrap to work with Rails 6

不想你离开。 提交于 2019-12-24 00:55:38
问题 I am a new to rails and struggling to get Jquery and Bootstrap to work with Rails 6. I think it has something to do with switching the app from rails 5 to rails 6 and using webpacker to load Jquery rather than loading it as a gem. I have gone through the instructions for this however it still doesn't seem to work properly. Someone helped me with a more specific problem and got me to paste this into the view which then seemed to make it work: <script src="https://code.jquery.com/jquery-3.3.1

Is there a way to test if PostCSS Autoprefixer is working? Specifically for Rails 6

*爱你&永不变心* 提交于 2019-12-23 17:24:03
问题 I am writing a Rails 6 webapp using Webpacker. Its my understanding that auto-prefixing in Rails 6 works out of the box via PostCSS and its autoprefixer plugin. However I cannot verify if this library is in fact prefixing my css or not. Is there a way to confirm if a standard default Rails 6.0.0 app auto-prefixes out of the box? I have run yarn autoprefixer --info to see the css rules and browsers it applies to and its def applying to my browser chrome 77 . And I tried using a parameter that