0.0.1-alpha.19 • Published 2 years ago

@lingxiteam/less-theme-change-webpack-plugin v0.0.1-alpha.19

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

less-theme-change-webpack-plugin

Refer to the antd-theme-webpack-plugin for dynamically changing less theme and based on its own business scenarios in browser (mainly used to modify less variables).

This plugin will change the index.html file content by inserting:

  • A script that contains init the window.less
  • A script that import the less.js
  • A link that import the less theme style file output by this plugin

Install

$ npm install -D @lingxiteam/less-theme-change-webpack-plugin

or

$ yarn add -D @lingxiteam/less-theme-change-webpack-plugin

Usage

Plugin init

const LessThemeChangePlugin = require('@lingxiteam/less-theme-change-webpack-plugin');

const options = {
  htmlFilePath: 'index.html',
  themeFileEntryPath: '',
  themeFileOutputPath: 'theme.txt', // .txt file is smaller than .less
  lessJsFilePath: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js',
  replaceContentsMapping: {
    'the content of theme style file ready to be replaced': 'the new content',
  }
};

const LessThemeChangePluginIns = new LessThemeChangePlugin(options);

Coding

// for Example: modify the antd less vars
window.less.modifyVars({
  '@primay-color': '#4477ee',
  '@success-color': '#33ee33',
  // ...
});

Options

PropertyTypeDefaultDescript
htmlFilePathstringindex.htmlThe project html file path
themeFileEntryPathstring''The Entry of less theme style file to be bundled
themeFileOutputDirstring''Specify the bundled less theme style file directory for additional output
bundleThemeFileOnlybooleanfalseOnly output the bundled less theme style file
bundleThemeFileNamestringtheme.txtThe bundled less theme style file output to dist directory by plugin
publicPathstring''The publicPath must be set as the publicPath of the project, and will be reflected in the path of introducing the bundled less theme style file in HTML
lessJsFilePathstringhttps://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.jsless.js cdn or file path
nodeModulesPathstring''Specify the path where the module is located (e.g. ~antd)
replaceContentsMappingobject{}The themeStyleFile content replace mapping { key: value } ( key is the replaced content, value is the new content, both are string )
0.0.1-alpha.19

2 years ago

0.0.1-alpha.18

2 years ago

0.0.1-alpha.17

2 years ago

0.0.1-alpha.16.1

2 years ago

0.0.1-alpha.16

2 years ago

0.0.1-alpha.15

2 years ago

0.0.1-alpha.14

2 years ago

0.0.1-alpha.13

2 years ago

0.0.1-alpha.12

2 years ago

0.0.1-alpha.11

2 years ago

0.0.1-alpha.10

2 years ago

0.0.1-alpha.9

2 years ago

0.0.1-alpha.8

2 years ago

0.0.1-alpha.7

2 years ago

0.0.1-alpha.6

2 years ago

0.0.1-alpha.5

2 years ago

0.0.1-alpha.4

2 years ago

0.0.1-alpha.3

2 years ago

0.0.1-alpha.2

2 years ago

0.0.1-alpha.1

2 years ago