gruntjs:使用多个任务多次修改文件的策略[关闭](gruntjs: strategy to modify a file more than once using several tasks [c

编程入门 行业动态 更新时间:2024-10-27 12:31:45
gruntjs:使用多个任务多次修改文件的策略[关闭](gruntjs: strategy to modify a file more than once using several tasks [closed])

您对以下方案的策略是什么:

我有:app / demo.less

我想:dist / demo.css

在我想要的中间:

使用regexp进行一些搜索/替换 自动添加供应商前缀 想要编译到更少

对于每一步,都很容易定义源和目标。

但你怎么工作? 您是否为每个中间步骤创建一个文件并正确命名? 你是在第一步创建一个dist文件并在之后改变它吗?

提前致谢。

What is your strategy for the following scenario:

I have: app/demo.less

I want: dist/demo.css

Inbetween I want:

do some search/replace using regexp add vendor-prefixes automatically want to compile to less

For every single step it is easy to define source and destination.

But how do you work? Do you create a file for every intermediate step and name it properly? Do you create a file in dist in the first step and change inplace afterwards?

Thanks in advance.

最满意答案

我会说2是最好的方法。 根据正则表达式的作用,您可能希望首先执行此操作,但我会说您将LESS处理为CSS,然后执行搜索和替换,然后自动添加您的供应商前缀。 生成中间文件没有任何意义,因为您之后很可能需要删除它们; 除非你这样做是为了调试目的。

您会发现这三项任务完全符合您的需求:

https://github.com/gruntjs/grunt-contrib-less https://github.com/nDmitry/grunt-autoprefixer https://github.com/erickrdch/grunt-string-replace

I'd say 2 is the best approach. Depending on what the regex is doing you may want to do this first, but I would say to process your LESS into CSS, then do search and replace, then add your vendor prefixes automatically. There's no real sense to generate intermediary files as you'll most likely need to remove them afterwards; unless you are doing so for debugging purposes.

You'll find that these three tasks do exactly what you need:

https://github.com/gruntjs/grunt-contrib-less https://github.com/nDmitry/grunt-autoprefixer https://github.com/erickrdch/grunt-string-replace

更多推荐

本文发布于:2023-08-02 17:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1380033.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   策略   文件   gruntjs   strategy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!