LoginSignup
0
0

More than 3 years have passed since last update.

webpackでSwiperをビルドする際にpolyfillが効かないとき

Posted at

以下のようにswiperをインポートする場合、
そのままだと、swiperと依存関係にあるモジュールたちがトランスパイルされない。
(swiperのv3.4.2以降)

app.js
import Swiper from 'swiper

対処方法

webpack.config.jsのモジュールの除外設定から
dom7とswiperを外すと解消されるかも。

webpack.config.js
module.exports = {
  // 省略
  module: {
    rules: [{
      test: /\.js$/,
      exclude: [/node_modules\/(?!(dom7|swiper)\/).*/],
      use: [{
        loader: 'babel-loader'
      }]
    }]
  },
  // 省略
};
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0