0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

webpackを使ってobjectFitをIEに対応させる

Posted at

webpackでobjectFitImagesを使えるようにするのははじめてだったので手順を残す。

最低限必要なのはライブラリだけ。
https://github.com/fregante/object-fit-images

object-fit-imagesをインストールする

yarn add object-fit-images

読み込ませるためのjsを書く

objectFitImages.js
/*
 * This file is use object-fit-images
 * IEをobjectFitに対応させるためのライブラリ
 * https://www.npmjs.com/package/object-fit-images
 *
*/
import objectFitImages from 'object-fit-images'

objectFitImages()

後はapp.tsなりにimportすればおk。

IEにも対応する

全てのCSSにfont-familiyを書いていくのは手間なので、postCssを使う。
https://github.com/ronik-design/postcss-object-fit-images

yarn add -D postcss-object-fit-images

postcss.configに追記

const objectFitImages = require('postcss-object-fit-images')
const autoprefixer = require('autoprefixer')

module.exports = {
  plugins: [
    autoprefixer,
    objectFitImages,
  ],
}

終わり。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?