Created
September 26, 2018 11:08
-
-
Save bbugh/bcc14a4e9266a5e6578c849b39f35dcd to your computer and use it in GitHub Desktop.
iconfont-webpack-plugin setup on webpack 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use with <i class="svg-icon bank-icon"></i> | |
.svg-icon { | |
vertical-align: middle; // you may not need this line depending on your icons | |
} | |
// borrowed from icomoon's font output | |
.svg-icon::before { | |
font-weight: normal; | |
font-style: normal; | |
font-variant: normal; | |
line-height: 1; | |
speak: none; | |
/* Better Font Rendering =========== */ | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} | |
// this is where the magic happens - point this to your svg and all of them will be converted into a font! | |
.bank-icon::before { | |
font-icon: url('../../icons/bank.svg'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is for Vue CLI3's webpack config but it should work fine on any Webpack4 postcss-loader config. | |
// See the official docs for the basic setup: https://www.npmjs.com/package/iconfont-webpack-plugin#configuration | |
const merge = require('deepmerge') | |
const IconfontWebpackPlugin = require('iconfont-webpack-plugin'); | |
module.exports = { | |
chainWebpack: config => { | |
config | |
.module | |
.rule('scss') | |
.oneOf('normal') | |
.use('postcss-loader') | |
.tap(options => merge(options, { | |
plugins: (loader) => new IconfontWebpackPlugin(loader) | |
})) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment