简体   繁体   English

使用玉石时如何使Grunt文件实时重载?

[英]How to make a Grunt file live reload when using jade?

I'm new to grunt and have been trying to make a development environment where on change to a Jade file to activate live reload. 我是刚接触新手,一直在尝试创建一个开发环境,在该环境中更改Jade文件以激活实时重新加载。

I have been able to turn on live reload when using a vanilla HTML file using a grunt express server. 使用grunt express服务器使用香草HTML文件时,我已经能够打开实时重新加载。

express: {
all: {
    options: {
        bases: ['C:\\location\\projectfolder'],
        port: 8080,
        hostname: "0.0.0.0",
        livereload: true
    }
}

}, },

I have also tried to compile the jade just afterwards then have the watch function afterwards. 我还尝试过编译玉器,然后再具有手表功能。

jade: {
 html: {
files: {
  'C:\\Users\\pavni_000\\Documents\\Business\\learning\\jade\\projectfolder': ['C:\\Users\\pavni_000\\Documents\\Business\\learning\\jade\\projectfolder\\text.jade']
},
options: {
  client: false
}
}
}

Could someone give me some guidance on how to make it so that any changes to the jade file (and any other project code in general) using grunt or any other tool? 有人可以给我一些指导,使它使用grunt或其他工具对jade文件(以及一般的其他项目代码)进行任何更改吗?

Sounds like you need a file watcher. 听起来您需要一个文件监视程序。 I use WebStorm IDE and it can be configured to use a Jade file watcher that continually compiles to html in real-time. 我使用WebStorm IDE,并且可以将其配置为使用Jade文件监视程序,该监视程序不断实时地编译为html。 So long as you have Jade installed on your machine, point the watcher to the Jade command (windows will be something like C:\\Users\\~USERNAME\\AppData\\Roaming\\npm\\jade.cmd, Linux/OSX would probably be /usr/local/bin/jade). 只要您在计算机上安装了Jade,就将监视程序指向Jade命令(Windows类似于C:\\ Users \\〜USERNAME \\ AppData \\ Roaming \\ npm \\ jade.cmd,Linux / OSX可能是/ usr / local / bin / jade)。

So then if you already have Grunt running a livereload server, it will pickup the html files your watcher updates. 因此,如果您已经有Grunt运行livereload服务器,它将拾取您的观察者更新的html文件。 There MAY be a way to do this all within grunt if you aren't using an IDE with a watcher (have Grunt's live-reload trigger a Jade compilation), but this method works fine for me. 如果您不使用带有观察程序的IDE(可能有Grunt的所有方法)(让Grunt的live-reload触发了Jade编译),但是这种方法对我来说很好用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM