2016-11-27 8 views
0

私はWordPressサイトでMAMPでgrunt-uncssを使用しています。私はすべての私のCSSファイルを撮影し、それらを1つのファイルにまとめました。Grunt Uncss PhantomJS Wordpress ReferenceError:変数が見つかりません:JQuery

結果:1つのURLが完了するまでに40分かかります。それは効率的ではありません。さらに、uncssはそれが始まった同じCSSを吐き出すだけです。

エラーの多くは "ReferenceError:変数を見つけることができません:jQuery"ですが、そのようなPhantomJS/UnCSSはインラインJavaScriptを解析しようとしていますか?ここで

は、いくつかの他は、次のとおりです。

にSyntaxError:予期しないトークン '%'

ローカル:2 にSyntaxError:識別子に無効なエスケープ: '\'

ローカル:427のsetContent 193 setContentで :2 にSyntaxError:予期しないトークン '<'

ローカル:891のsetContentで :2 SyntaxError:予期しないトークン '、'

jQueryをロードするための時間(タイムアウト)の追加や過去7時間の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

OKです。私は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' 
    }] 

ヒント:あなたは、自分のホームページのソースを見て、彼らはページに表示特定のために、1つのCSSファイルにすべてのあなたのCSSをコピーする必要がありますワードプレスのためにソース(したがって - consolidated.css)。そうすれば、完成したサイトと同じくらい多くのCSSを継承することができます。

関連する問題