大佬教程收集整理的这篇文章主要介绍了gruntjs – Grunt在服务器上观看LiveReload,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Gruntfile:
@H_189_9@module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'),watch: { scripts: { options: { livereload: true },files: ['**/*.scss'],//tasks: ['criticalcss:front','criticalcss:page','cssmin','postcss'],} },postcss: { options: { processors: [ require('autoprefixer')({Browsers: 'last 6 versions'}),// add vendor prefixes //require('cssnano')() // minify the result ] },dist: { src: 'style.css',dest: 'style.css' } },criticalcss: { front : { options: { url: "https://grandeurflooring.ca/grand_dev/",minify: true,width: 1500,height: 900,outputfile: "critical_css/critical-front.css",filename: "style.css",buffer: 800*1024,ignoreConsole: true } },page : { options: { url: "https://grandeurflooring.ca/grand_dev/sample-page/",outputfile: "critical_css/critical-page.css",ignoreConsole: true } } },cssmin: { target: { files: [{ expand: true,cwd: 'critical_css',src: ['*.css','!*.min.css'],dest: 'critical_css',ext: '.min.css' }] } } }); // Load the plugin that provides the "critical" task. grunt.loadNpmTasks('grunt-criticalcss'); // Load the plugin that provides the "cssmin" task. grunt.loadNpmTasks('grunt-contrib-cssmin'); // Load the plugin that provides the "watch" task. grunt.loadNpmTasks('grunt-contrib-watch'); // Load the plugin that provides the "PostCSS" task. grunt.loadNpmTasks('grunt-postcss'); // Critical task. grunt.registerTask('critical',['criticalcss:front']); };
在footer.PHP中,在wp_footer()之前,我把脚本放了:
<script src="http://localhost:35729/livereload.js"></script>
这是我的手表配置,它实现了你想要的:
watch: { options: { livereload: true,},html: { files: ['index.html'],js: { files: ['js/**/*.js'],tasks: ['jshint'],sass: { options: { livereload: false },files: ['css/scss/**/*.scss'],tasks: ['sass'],css: { files: ['dist/css/master.css'],tasks: [] } }
您可能需要将spawn:false更改为spawn:true,具体取决于您的设置.
编辑:此外,您可以使用grunt-contrib-watch插件,它允许您:
此插件包含许多其他选项,可用于实时重新加载,观看等,您可能会觉得这些选项很有用.
以上是大佬教程为你收集整理的gruntjs – Grunt在服务器上观看LiveReload全部内容,希望文章能够帮你解决gruntjs – Grunt在服务器上观看LiveReload所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。