Skip to content

byself/rem-webpack-plugin

Repository files navigation

Rem Webpack Plugin

NPM NPM

一款向html中插入rem自适应脚本的插件

Install

  npm i --save-dev rem-webpack-plugin
  yarn add --dev rem-webpack-plugin

该插件依赖html-webpack-plugin。如未安装,请按照如下方式安装:

  npm i --save-dev html-webpack-plugin
  yarn add --dev html-webpack-plugin

Usage

webpack.config.js

const RemWebpackPlugin = require('rem-webpack-plugin')

module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'main.js'
  },
  plugins: [
    new RemWebpackPlugin()
  ]
}

// width options
module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'main.js'
  },
  plugins: [
    new RemWebpackPlugin({
        root: 50,
        rootWidth: 375,
        maxWidth: 600
    })
  ]
}

Options

Name Type Default Description
root Number 100 如果使用了px2rem等类似的插件,请保持root配置一致
rootWidth Number 750 页面基础宽度
maxWidth Number 750 最大宽度,超过最大宽度时根节点的fontsize值不变

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published