使用webpack创建更少的捆绑包 [英] creating a less bundle with webpack

查看:49
本文介绍了使用webpack创建更少的捆绑包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用webpack创建一个bundle.less文件,该文件的行为与less-loader + exctract文本插件相同,除了它不应少编译为CSS,仅连接所有所需的较少文件并内联较少的导入.

I need to create a bundle.less file with webpack that behaves the same as less-loader + exctract text plugin EXCEPT that it should not compile less into css, only concatenate all the required less files and inline the less imports.

原因是我有一些在运行时会解析的变量(以允许用户自定义应用程序主题),但我想将其捆绑在生产捆绑的资源中,而不是整个源文件集合中.

The reason is that I have some variable that will be resolved at runtime (to allow the user to customize the application theme) but I want to ship in production bundled resources instead of the whole source file collection.

有没有办法用现有的插件来做到这一点,还是我需要编写一个 webpack 插件(我宁愿避免)?

Is there a way to do that with existing plugin or do I need to write a webpack plugin (which I would rather avoid)?

推荐答案

最后,我决定创建一个自定义Webpack加载器,该加载器以递归方式内联更少的导入.

In the end I decided to create a custom webpack loader that recursively inline less imports.

这篇关于使用webpack创建更少的捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆