next-theme-webpack-plugin
A webpack plugin for adding normalize css and icon css of theme package.
Forked from @alifd/next-theme-webpack-plugin, fix some bugs
Install
npm install babel-plugin-import --save-dev
npm install @alifd/next-theme-loader --save-dev
npm install next-theme-webpack-plugin --save-dev
Usage
webpack 2+
const path = ;const webpack = ;const ExtractTextPlugin = ;const ThemePlugin = ;moduleexports =entry:index: './src/index.jsx'output:path: pathfilename: '[name].js'resolve:extensions: '.js' '.jsx'devtool: 'inline-source-map'module:rules:test: /\.jsx?$/use:loader: 'babel-loader'options:presets:'env''react''stage-0'plugins:'add-module-exports''transform-decorators-legacy''babel-plugin-import' style: trueexclude: /node_modules/test: /\.css$/use: ExtractTextPlugintest: /\.scss$/use: ExtractTextPluginplugins:theme: '@alifd/theme-package''[name].css';
webpack 1
webpack.config.js
const path = ;const webpack = ;const ExtractTextPlugin = ;const ThemePlugin = ;moduleexports =entry:index: './src/index.jsx'output:path: pathfilename: '[name].js'resolve:extensions: '' '.js' '.jsx'devtool: 'inline-source-map'module:loaders:test: /\.jsx?$/loader: 'babel'query:presets:'es2015''react''stage-0'plugins:'add-module-exports''transform-decorators-legacy''babel-plugin-import' style: trueexclude: /node_modules/test: /\.css$/loaders: ExtractTextPlugintest: /\.scss$/loader: ExtractTextPluginplugins:theme: '@alifd/theme-package''[name].css';
Options
prependNormalizeCSS
(Boolean): whether prepend next build-in normalize css to bundle css, default value istrue
theme
(String): theme packageresolve
(String/Array): the path(node_modules parent folder) to find the theme packagelibraryName
(String): the basic component library name, default value is@alifd/next
modifyVars
(String/Object): inject some variables to build normalize scss and icon scss, such as:$css-prefix
or$font-custom-path
, value may be the following two types{ '$css-prefix': '"my-"' }
path.join(__dirname, 'variable.scss')
, it should be an absolute path