用grunt-contrib-connect预览了多个文件?

时间:2018-12-17 23:27:21

标签: gruntjs grunt-contrib-watch grunt-contrib-connect

我想使用实时重载在浏览器中同时预览index.htmlREADME.md文件。该设置适用于单个文件,但我无法使其适用于两个文件。

grunt.initConfig({
  connect: {
    // Server for the index.html inside the templates
    template: {
                options: {
                    hostname: 'localhost',
                    port: 3001,
                    base: './templates/price-table/',
                    livereload: true
                }
            },
    // Server for the README.md
    readme: {
                options: {
                    hostname: 'localhost',
                    port: 3002,
                    base: '.',
                    livereload: true
                }
            },
  watch: {
        // Watch Templates.
        template: {
            options: {
                spawn: false,
                livereload: true
            },
            files: ['templates/price-table/**/*.html'],
        },
        // Watch Readme
        readme: {
            options: {
                spawn: false,
                livereload: true
            },
            files: ['README.md'],
        }
    }
}); //initConfig

// load npm tasks
 grunt.loadNpmTasks('grunt-contrib-watch');
 grunt.loadNpmTasks('grunt-contrib-connect');

 // define default task
 grunt.registerTask('default', ['connect:template', 'connect:readme', 'watch:template', 'watch:readme']);

设置方法是什么?

0 个答案:

没有答案