Ruby on RailsでWebpackerのエイリアスを設定する方法

Ruby on Rails JavaScript

Updated by Yuto Yasunaga at 2021/01/24 06:00
config/webpack/environment.js
const { resolve } = require('path')

environment.config.merge({
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('app/javascript/packs'),
      '&': resolve('app/javascript/packs/components'),
    },
  },
})

サーバーの再起動が必要です。


Back