WordPressサイトでMAMPでgrunt-uncssを使用しています。すべての css ファイルを取得し、それらを 1 つのファイルに結合しました。
結果: 1 つの URL が完了するまでに 40 分かかります。それは効率的ではありません。さらに、uncss は、開始時と同じ css を吐き出すだけです。
エラーの多くは「ReferenceError: 変数が見つかりません: jQuery」ですが、PhantomJS/UnCSS がインライン JavaScript を解析しようとしているようなものですか?
ここにいくつかの他のものがあります:
SyntaxError:予期しないトークン '%'
local:193 in setContent:2 SyntaxError: 識別子の無効なエスケープ: '\'
local:427 in setContent:2 SyntaxError: 予期しないトークン '<'
local:891 in setContent:2 SyntaxError: 予期しないトークン ','
jQueryの読み込み時間(タイムアウト)の追加など、さまざまなアプローチを試しました。また、過去7時間のグーグル検索も試しました。問題は PhantomJS にあると確信していますが、それに慣れていません。助けを求めている
これが私のグラントファイルです
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']);
};