簡體   English   中英

在grunt服務之前運行grunt-preprocess

[英]Run grunt-preprocess before grunt serve

我需要在執行grunt serve task之前運行grunt-preprocess ,以便使用開發設置更新index.html

是否可以不修改index.html位置?

在dist進程中,在將index.html復制到dest文件夾后,我運行grunt-preprocess任務。

您可以定義運行grunt serve時需要執行的任務列表,其方式類似於yeoman的方式。 您的最終結果可能是這樣的:

grunt.registerTask('serve', 'start the server and preview your app', [
    'clean:dist',
    'copy',
    'preprocess',
    'connect:livereload',
    'open',
    'watch'
  ]);

您基本上是使用grunt.registerTask注冊alias任務的。

如果指定了任務列表,則新任務將是一個或多個其他任務的別名。 每當運行此“別名任務”時,都會按照指定的順序運行taskList中的每個指定任務。

換句話說,如果您已經使用了諸如grunt-serve之類的任務,那么您將已經有一個名為serve的任務,您將對其進行別名,如以下示例所示:

grunt.registerTask('serve', 'start the server and preview your app', [
    'clean:dist',
    'copy',
    'preprocess',
    'serve:dist'
  ]);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM