Rails 5: loading static assets from a yarn package

时间:2018-02-05 12:56:52

标签: ruby-on-rails webpacker vue2-dropzone

I'm currently using vue2-dropzone for a Rails 5 project. I've installed it with yarn add vue2-dropzone. The package includes its styles from the rollup.config.js file, as such:

export default {
  moduleName: 'vue2Dropzone',
  entry: 'src/index.js',
  dest: 'dist/vue2Dropzone.js',
  format: 'umd',
  sourceMap: true,
  plugins: [
    vue({
      compileTemplate: true,
      css: 'dist/vue2Dropzone.css' // Here we are :)
    }),
    ...
  ]
};

While this is displaying correctly for other users, Rails or Webpacker doesn't seem to pick those assets up (i.e. vue2Dropzone.css).

How does Rails/Webpacker load dependencies or static assets? Why wouldn't this file be loaded? Thanks in advance!

1 个答案:

答案 0 :(得分:1)

您希望配置config/webpack.yml并包含资产的路径。见this。我一直在为这些类型的组件创建单独的包,然后将它们与应用程序包分开添加到erb中。