使用modifyvars时如何热重新加载

Yic*_*aoz 7 less webpack

目前我正在使用less-loader以及modifyVars覆盖一些较少的变量以自定义样式.

在我的webpack.config.js中

import theme from './theme.js';

{
        test: /\.(css|less)$/,
        loaders: ['style', 'css?sourceMap', 'postcss', `less-loader?{"sourceMap":true,"modifyVars":${JSON.stringify(theme)}}`],
      },
Run Code Online (Sandbox Code Playgroud)

但是对于theme.js中的每一个更改我都必须重新启动服务器,(执行npm运行)有没有办法让它自动就像我更改一个较少的文件并立即更换?

theme.js

module.exports = {
  '@primary-color': '#1DA57A',
  '@font-size-base': '14px',
  '@btn-font-weight': '200',
};
Run Code Online (Sandbox Code Playgroud)

Rat*_*ica 1

如果由于当前存在的问题而不能,“我们需要接受一个 {Function} 来修改变量并在加载器内处理它”。