代码之家  ›  专栏  ›  技术社区  ›  mbilyanov

使用grunt contrib connect预览多个文件?

  •  0
  • mbilyanov  · 技术社区  · 6 年前

    我想预览我的 index.html 还有我的 README.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 回复  |  直到 6 年前