Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5.1 app with Vue and webpacker 3, css not compiled

I'm trying to add Element UI to my Vue app. I follow the quick start tutorial and I have my application.js

import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/it'
import App from '../app.vue'

Vue.use(ElementUI, { locale })

document.addEventListener('DOMContentLoaded', () => {
  document.body.appendChild(document.createElement('app'))
  const app = new Vue(App).$mount('app')

  console.log(app)
})

I'm importing the CSS and I have also

<%= stylesheet_link_tag 'application' %>

Inside my layout, but this file is empty, no styles. The app is working, but without the CSS. Where is my fault?

like image 903
Roberto Pezzali Avatar asked Nov 10 '17 12:11

Roberto Pezzali


1 Answers

The problem is in the import method

Use

<%= stylesheet_pack_tag 'application', media: 'all' %>

Instead of

<%= stylesheet_link_tag 'application' %>

based on: https://github.com/rails/webpacker/issues/987

like image 52
Igor Paiva Ferreira Avatar answered Oct 25 '22 12:10

Igor Paiva Ferreira