Giter VIP home page Giter VIP logo

convremvw-loader's Introduction

convremvw-loader

Rem or vm conversion 可以转换 rem 又可以转换 vm 的 loader

安装

npm install convremvw-loader

默认转换 rem,如果是 rem 还需引入来进行根元素font-size的变化

function resize() {
      let dom = document.documentElement||document.body
    dom.setAttribute('style', 'font-size:' + dom.clientWidth / 7.5 + 'px !important');
}
document.addEventListener('DOMContentLoaded', function () {
    resize()
    window.onresize = function () {
        resize()
    }
})

参数

module: {
  rules: [{
    test: /\.css$/,
      use: [{
        loader: 'convremvw-loader',
        query: {
         unit: 'rem'或者是'vw'
        }
      }, {
        loader: "css-loader"
      }]
  }]
}

忽略转换

如需元素不转换单位 在属性值后面加/*i*/即可

.test{
  width:100px/*i*/;
}

convremvw-loader's People

Contributors

huatao1990 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.