grunt watch和livereload配合,但是通过grunt端口访问所有资源加载失败了

1.通过配置后,启动grunt命令,通过端口号访问我的HTML页面,但是页面的资源无法加载时怎么回事。初了和除了和gruntfile同级下面的index的资源是可以加载成功的。。文件结构如下,代码配置没问题吧,实时监听文件也起了效果,就是在页面刷新上有些问题,不能通过路由来访问加载该地址资源。。。

clipboard.png

grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),//读取json配置文件
    watch: {
        livereload: {
            options: {
                livereload: '<%= connect.options.livereload %>'
            },
            files: [
                'pages/**/*.html',
                'js/*.js'
            ]
        }
    },
    connect: {
        options: {
            port: 9000,
            open: true,
            livereload: 35729,
            // Change this to '0.0.0.0' to access the server from outside
            hostname: 'localhost'
        },
        server: {
            options: {
                port: 9001,
                base: ''
            }
        }
    }
});
阅读 2.6k
1 个回答

调整connect中的server中的base目录基础 就可以

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进