px2rem-loader升级版,以支持webpack2.0
npm i -D lmw-px2rem-loader
var pxUnit = 100; // 在px2rem中预设rem的值 即 1rem = ? px
var designWid = 750; // 设计稿宽度
var winWid = window.innerWidth;
var bl = winWid / designWid;
document.querySelector('html').style.fontSize = (bl * pxUnit) + 'px';
var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) {
var sc = 1 / window.devicePixelRatio;
document.getElementsByName('viewport')[0].content = 'initial-scale='+ sc +', maximum-scale='+ sc +', minimum-scale='+ sc +', user-scalable=no';
}
utils.js
+var px2rem = {
+ loader: "lmw-px2rem-loader",
+ options:{
+ remUnit:100
+ }
+ }
// generate loader string to be used with extract text plugin
function generateLoaders(loader, loaderOptions) {
- var loaders = [cssLoader]
+ var loaders = [cssLoader,px2rem]