2016-11-27 65 views
0

我正在MAMP上使用grunt-uncss和一个WordPress站点。我把我所有的css文件都合并成了一个文件。Grunt Uncss PhantomJS Wordpress ReferenceError:无法找到变量:JQuery

结果:一个网址需要40分钟才能完成。这不是有效的。另外,uncss只是吐出与之前相同的css。

许多错误是“ReferenceError:无法找到变量:jQuery”,但它像PhantomJS/UnCSS试图解析内联JavaScript?

下面是一些其它:

语法错误:意外标记 '%'

本地:193 setContent :2 语法错误:在标识符无效的转义: '\'

本地:427在setContent :2 语法错误:意外令牌 '<'

地方:891 setContent :2 SyntaxError:意外的令牌','

我已经尝试了不同的方法,包括加载更多的时间(超时)jQuery加载等,以及goo'gling过去七个小时。我很确定问题出在PhantomJS上,但我不太熟悉它。寻找帮助

这里是我的gruntfile

module.exports = function(grunt) { 

    require('time-grunt')(grunt); 

    // 1. All configuration goes here 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 

     jshint: { 
     all: ['gruntfile.js'] 
     }, 

    exec: { 
     get_grunt_sitemap: { 
     command: 'curl --silent --output sitemap.json http://localhost:8888/applus/?show_sitemap' 
     } 
    }, 

    uncss: { 
    dist: { 
     options: { 
     ignore  : [ 
       /expanded/, 
       /js/, 
       /wp-/, 
       /align/, 
       /admin-bar/, 
       /\w\.in/, 
       ".fade", 
       ".collapse", 
       ".collapsing", 
       /(#|\.)navbar(\-[a-zA-Z]+)?/, 
       /(#|\.)dropdown(\-[a-zA-Z]+)?/, 
       /(#|\.)(open)/, 
       ".modal", 
       ".modal.fade.in", 
       ".modal-dialog", 
       ".modal-document", 
       ".modal-scrollbar-measure", 
       ".modal-backdrop.fade", 
       ".modal-backdrop.in", 
       ".modal.fade.modal-dialog", 
       ".modal.in.modal-dialog", 
       ".modal-open", 
       ".in", 
       ".modal-backdrop", 
       '.hidden-xs', 
       'hidden-sm' 

       ], 
     stylesheets : ['wp-content/themes/vest/css/consolidated.css'], 
     ignoreSheets : [/fonts.googleapis/], 
     urls   : [], //Overwritten in load_sitemap_and_uncss task 
    }, 
    files: { 
     'wp-content/themes/vest/style.test.css': ['**/*.php'] 
    } 
    } 
} 

    }); 

// 3. Where we tell Grunt we plan to use this plug-in. 
     grunt.loadNpmTasks('grunt-contrib-jshint'); 
     grunt.loadNpmTasks('grunt-exec'); 
     grunt.loadNpmTasks('grunt-uncss'); 

// 4. Where we tell Grunt what to do when we type "grunt" into the terminal. 
     grunt.registerTask('load_sitemap_json', function() { 
     var sitemap_urls = grunt.file.readJSON('./sitemap.json'); 
     grunt.config.set('uncss.dist.options.urls', sitemap_urls); 
}); 

    grunt.registerTask('deploy'['jshint','exec:get_grunt_sitemap','load_sitemap_json','uncss:dist']); 
}; 

回答

0

好了,回答我的问题。似乎我错误地配置了MAMP的样式表和文件url?只要我创建了硬链接到文件。除了那些由用户交互触发的事件之外,一切似乎都奏效。

下面是我所做的更改:

stylesheets : ['http://localhost:8888/wp-content/themes/vest/css/consolidated.css'], 



files: [{ 
       nonull: true, 
       src: ['http://localhost:8888/applus'], 
       dest: '/Applications/MAMP/htdocs/applus/wp-content/themes/cannavest/uncss-style.css' 
    }] 

提示:WordPress的,你应该看看你的页面的源代码和所有你的CSS复制到一个CSS文件中,他们在页面显示的特定顺序源(因此 - consolidated.css)。这样你可以保持尽可能多的css继承你的完成的网站。

相关问题