Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScriptConcat加载页面之前的更改不是最新的,之后使用livereload进行GruntWatch_Javascript_Gruntjs_Livereload_Grunt Contrib Watch - Fatal编程技术网

JavaScriptConcat加载页面之前的更改不是最新的,之后使用livereload进行GruntWatch

JavaScriptConcat加载页面之前的更改不是最新的,之后使用livereload进行GruntWatch,javascript,gruntjs,livereload,grunt-contrib-watch,Javascript,Gruntjs,Livereload,Grunt Contrib Watch,我正在做一个角度的应用程序。在css和js文件上运行其他任务后,我正在努力让grunt contrib watch和livereload正常工作 基本上,我会做以下工作: JsHint,Concatenate&uglify-the-js-on-change 对css更改运行autoprefixer 这两个文件都会创建新文件,我会将其包含在索引页中 创建这些新文件时,我希望在浏览器中实时重新加载它们 以下是我的Grunfile.js: grunt.initConfig({ pkg: grunt

我正在做一个角度的应用程序。在css和js文件上运行其他任务后,我正在努力让grunt contrib watch和livereload正常工作

基本上,我会做以下工作:

  • JsHint,Concatenate&uglify-the-js-on-change
  • 对css更改运行autoprefixer
  • 这两个文件都会创建新文件,我会将其包含在索引页中

    创建这些新文件时,我希望在浏览器中实时重新加载它们

    以下是我的Grunfile.js:

    grunt.initConfig({
      pkg: grunt.file.readJSON('package.json'),
      autoprefixer: {
        dist: {
            files: {
                'webapp/assets/css/build/rm.css': 'webapp/assets/css/pre/rm.css'
            }
        },
        options: {
            browsers: ['Explorer >= 8', '> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']
        }
    },
    concat: {   
        dist: {
            src: [
                'webapp/app.js',  // This specific file
                'webapp/shared/**/*.js', // All the shared angular files
                'webapp/specific/**/*.js', // All the page specific angular files
                '!webapp/shared/tests/*.js', //Remove tests
                '!webapp/specific/*/tests/*.js' //Remove tests
            ],
            dest: 'webapp/assets/libs/production.js',
        }
    },
    uglify: {
        options: {
          banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
        },
        build: {
            src: 'webapp/assets/libs/production.js',
            dest: 'webapp/assets/libs/production.min.js'
        }
    },
    jshint: {
        options: {
            reporter: require('jshint-stylish'),
            predef: [ "angular", "describe", "beforeEach", "module", "inject", "expect", "it" ]
        },
        target: ['webapp/app.js', 'webapp/shared/**/*.js', 'webapp/specific/**/*.js']
    },
    watch: {
        scripts: {
            files: ['webapp/app.js', 'webapp/shared/**/*.js', 'webapp/specific/**/*.js', 
                    '!webapp/shared/tests/*.js', '!webapp/specific/*/tests/*.js'], 
            tasks: ['jshint', 'concat', 'uglify'],
        },
        styles: {
            files: ['webapp/assets/css/pre/*.css'],
            tasks: ['autoprefixer'],
        },
        livereload: {
            options: {
              livereload: true,
            },
            files: ['webapp/assets/libs/production.js',
                    'webapp/assets/libs/production.min.js',
                    'webapp/assets/css/build/rm.css', 
                    'webapp/shared/**/*.html', 
                    'webapp/specific/**/*.html', 
                    'webapp/index.html']
        },        
      }
    
    grunt.initConfig({
    pkg:grunt.file.readJSON('package.json'),
    自动刷新器:{
    地区:{
    档案:{
    “webapp/assets/css/build/rm.css”:“webapp/assets/css/pre/rm.css”
    }
    },
    选项:{
    浏览器:['Explorer>=8','>1%,'last 2 versions','Firefox ESR','Opera 12.1']
    }
    },
    concat:{
    地区:{
    src:[
    'webapp/app.js',//此特定文件
    'webapp/shared/***.js',//所有共享文件
    'webapp/specific/***.js',//所有页面特定的角度文件
    “!webapp/shared/tests/*.js”,//删除测试
    “!webapp/specific/*/tests/*.js”//删除测试
    ],
    dest:'webapp/assets/libs/production.js',
    }
    },
    丑陋的:{
    选项:{
    横幅:'/*!*/\n'
    },
    建造:{
    src:'webapp/assets/libs/production.js',
    dest:'webapp/assets/libs/production.min.js'
    }
    },
    jshint:{
    选项:{
    记者:require('jshint-style'),
    predef:[“角度”、“描述”、“之前”、“模块”、“注入”、“预期”、“它”]
    },
    目标:['webapp/app.js','webapp/shared/***.js','webapp/specific/***.js']
    },
    观察:{
    脚本:{
    文件:['webapp/app.js','webapp/shared/***.js','webapp/specific/***.js',
    “!webapp/shared/tests/*.js',”!webapp/specific/*/tests/*.js'],
    任务:['jshint','concat','uglify'],
    },
    风格:{
    文件:['webapp/assets/css/pre/*.css'],
    任务:['autoprefixer'],
    },
    利弗雷罗德:{
    选项:{
    利弗雷罗德:没错,
    },
    文件:['webapp/assets/libs/production.js',
    “webapp/assets/libs/production.min.js”,
    “webapp/assets/css/build/rm.css”,
    “webapp/shared/***.html”,
    “webapp/specific/***.html”,
    “webapp/index.html”]
    },        
    }
    
    }))

    在我的index.html中,我包括构建的css和production.min.js文件:

    <link rel="stylesheet" href="assets/css/build/rm.css">
    <script type="text/javascript" src="assets/libs/production.min.js"></script>
    
    
    
    我已经尝试了使用Chrome扩展和将脚本标记添加到我的HTML中的实时重新加载

    我的手表输出识别出production.min.js&build/rm.css后处理文件已更改

    我遇到以下两个问题:

  • 对于我的Javascript和HTML文件,它都是实时重新加载的,但是它没有 与以前一次的更改,而不是最新的更改。也就是说,它落后一个变化
  • 我的CSS根本不是实时重新加载的
  • 在我添加JSHint、concat和丑陋任务之前,livereload似乎工作正常


    谁能告诉我我做错了什么?这是一个时间滞后问题吗?

    很抱歉,这有点离题,但您的操作系统和浏览器是什么?使用Windows 8.1和Chrome时,Live reload始终会在我身上崩溃。我也在使用Windows 8.1和Chrome。它没有崩溃,但也不能正常工作。你成功修复了吗?