webpacker

Rails Webpacker 3.0 import CSS file is not working

孤街醉人 提交于 2019-12-05 02:15:10
I am working Rails5 project with Webpacker in order to run React properly But when import my css file inside my root component seems it is not working at all. Looking like stylesheet is not coming at all. This is my root Component import React from 'react' import ReactDOM from 'react-dom' import StartForm from './insurance_form/start_form' //import PropTypes from 'prop-types' import 'react-datepicker/dist/react-datepicker.css'; // not working ReactDOM.render( <StartForm />, document.getElementById('start-form-index-container') ) This my webpack/environment.js const { environment } = require('

stylesheet_pack_tag not finding app/javascript/src/application.css in rails 5.1 with webpacker gem

主宰稳场 提交于 2019-12-04 22:30:51
I am receiving this error when I try to load a page in my new rails 5.1 app using webpacker. I would like webpacker to handle CSS as well. Started GET "/" for ::1 at 2017-09-01 12:20:23 -0400 Processing by HomeController#welcome as HTML Rendering home/welcome.html.erb within layouts/application Rendered home/welcome.html.erb within layouts/application (0.4ms) Completed 500 Internal Server Error in 28ms ActionView::Template::Error (Webpacker can't find application.css in /Users/myusername/Documents/testing-ground/myapp/public/packs/manifest.json. Possible causes: 1. You want to set wepbacker

How to handle images in a Rails / Webpacker / React app?

最后都变了- 提交于 2019-12-04 00:14:41
I'm using webpacker with rails 5.1.4 to play with Reactjs, Redux, and react-router-dom. I have a navbar component that needs to display images, but I'm not able to access images in assets/images folder and neither in public folder. I'm here : app/javascript/src/components/navbar My routes defined in main.jsx : <BrowserRouter> <div> <Alert error={error} /> <Navbar user={user}/> <Switch> <Route path="/post/:id" component={PostsShow} /> <Route path="/" component={PostsIndex} /> </Switch> </div> </BrowserRouter> Here is what I've tried : <img src="logo.png" alt="Logo" /> <img src="assets/logo.png"

Pass data from Rails views to VueJS components in webpacker

谁说胖子不能爱 提交于 2019-12-03 21:48:23
I'm trying to fiddle with Rails 5.1's new webpacker gem, along with VueJS, but can't get my erb views to pass data to VueJS components... Let's say I have a user show view # view/users/show.html.erb <%= javascript_pack_tag "user-card" %> <%= content_tag :div, id: "user-card", data: { username: @user.name } do %> <% end %> And my javascript: // app/javascript/packs/user-card.js require("user-card") // app/javascript/user-card/index.js import Vue from 'vue/dist/vue.esm' import UserCard from './components/UserCard' document.addEventListener('DOMContentLoaded', () => { let element = document

Webpacker throws application.css not found in manifest.json in *Rails 6* application

你。 提交于 2019-12-01 07:40:27
问题 Currently we use Rails 6 for our application. It's working fine in production but in development mode it throws some errors. Please assist me. This is how my application.js and application.css looks like packs/application.js require("@rails/ujs").start() require("turbolinks").start() require("@rails/activestorage").start() require("channels") require("jquery") import '../stylesheets/application' import './bootstrap_custom.js' import './side_menu.js.erb' //import './sweetalert.js' import '.

Vue.js app works in development but not mounting template in production with Rails 5.2.0 / Webpacker - blank screen with no errors in console

筅森魡賤 提交于 2019-12-01 05:38:23
I'm using Rails 5.2.0 and Webpacker gem to deploy a Vue application. The show.html.erb file is very simple: <div data-behavior="vue-app"><MyComponent></MyComponent></div> And then in my entry pack, packs/my_vue_app.js: import TurbolinksAdapter from 'vue-turbolinks'; import Vue from 'vue/dist/vue.esm' Vue.use(TurbolinksAdapter); import MyComponent from '../components/my_app/index.vue' document.addEventListener('turbolinks:load', () => { var element = $('[data-behavior="vue-app"]'); if(!element) { return }; console.log('Initializing Vue'); const app = new Vue({ el: element[0], data: { },

Vue.js app works in development but not mounting template in production with Rails 5.2.0 / Webpacker - blank screen with no errors in console

时间秒杀一切 提交于 2019-12-01 03:32:01
问题 I'm using Rails 5.2.0 and Webpacker gem to deploy a Vue application. The show.html.erb file is very simple: <div data-behavior="vue-app"><MyComponent></MyComponent></div> And then in my entry pack, packs/my_vue_app.js: import TurbolinksAdapter from 'vue-turbolinks'; import Vue from 'vue/dist/vue.esm' Vue.use(TurbolinksAdapter); import MyComponent from '../components/my_app/index.vue' document.addEventListener('turbolinks:load', () => { var element = $('[data-behavior="vue-app"]'); if(!element

Using Rails-UJS in JS modules (Rails 6 with webpacker)

◇◆丶佛笑我妖孽 提交于 2019-11-27 16:03:38
问题 i just switched to Rails 6 (6.0.0.rc1) which uses the Webpacker gem by default for Javascript assets together with Rails-UJS. I want to use Rails UJS in some of my modules in order to submit forms from a function with: const form = document.querySelector("form") Rails.fire(form, "submit") In former Rails versions with Webpacker installed, the Rails reference seemed to be "globally" available in my modules, but now i get this when calling Rails.fire … ReferenceError: Rails is not defined How

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

*爱你&永不变心* 提交于 2019-11-27 09:00:58
I think this should be simple, but I am facing some trouble on how to import and use an image in Vue single file component. Can someone help me how to do this? Here is my code snippet: <template lang="html"> <img src="zapierLogo" /> </template> <script> import zapierLogo from 'images/zapier_logo.svg' export default { } </script> <style lang="css"> </style> I have tried using :src , src="{{ zapierLogo }}" , etc but nothings seems to work. was not able to find any example too. Any help? As simple as : <template> <div id="app"> <img src="./assets/logo.png"> </div> </template> <script> export

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

被刻印的时光 ゝ 提交于 2019-11-26 07:43:13
问题 I think this should be simple, but I am facing some trouble on how to import and use an image in Vue single file component. Can someone help me how to do this? Here is my code snippet: <template lang=\"html\"> <img src=\"zapierLogo\" /> </template> <script> import zapierLogo from \'images/zapier_logo.svg\' export default { } </script> <style lang=\"css\"> </style> I have tried using :src , src=\"{{ zapierLogo }}\" , etc but nothings seems to work. was not able to find any example too. Any