首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在XAMPP上运行的GRUNT + LESS + BROWSERSYNC

在XAMPP上运行的GRUNT + LESS + BROWSERSYNC
EN

Stack Overflow用户
提问于 2015-03-22 16:00:36
回答 1查看 1.7K关注 0票数 2

对于Grunt的BrowserSync版本,我有一个小问题。

问题:--如果我编辑.php文件-- BrowserSync工作得很好,但是如果我编辑了.less文件,什么都不会发生,但在bash中,我仍然可以看到:

BS文件更改: d:\localhost\htdocs\www\wordpress\wp-content\themes\MYPROJECTNAME\css\main.css

有人能帮助我正确地设置: GRUNT + LESS + BrowserSync在XAMPP上运行(因为WordPress)吗?

我的gruntfile.js

代码语言:javascript
复制
module.exports = function (grunt) {
    grunt.initConfig({
        // Watch task config
        watch: {
            less: {
                files: ['less/**/*.less'],
                tasks: ['less']
            }
        },
        // less task config
        less: {
            dev: {
                files: {
                    "/localhost/htdocs/www/wordpress/wp-content/themes/MYPROJECTNAME/css/main.css" // destination
                    :
                    "less/main.less" // source file
                }
            }
        },
        // Using the BrowserSync Proxy for your existing website url.        
        browserSync : {
            dev : {
                bsFiles : {
                    src : [
                    '/localhost/htdocs/www/wordpress/wp-content/themes/MYPROJECTNAME/**/*.php',
                    '/localhost/htdocs/www/wordpress/wp-content/themes/MYPROJECTNAME/images/*.*', 
                    '/localhost/htdocs/www/wordpress/wp-content/themes/MYPROJECTNAME/_dev/less/**/*.less', 
                    '/localhost/htdocs/www/wordpress/wp-content/themes/MYPROJECTNAME/**/*.css', 
                    ]
                },
                options : {
                    watchTask: true,
                    debugInfoě: true,
                    logConnections: true,
                    notify: true,
                    proxy: "localhost/www/wordpress",
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-browser-sync');

    // register a default task.
    grunt.registerTask('default', ['less', 'browserSync', 'watch']);
};

谢谢大家!-)

EN

回答 1

Stack Overflow用户

发布于 2015-04-01 17:31:54

这是我的背景

'localhost/htdocs/www/wordpress/wp-content/themes/MYPROJECTNAME/'; = var root

代码语言:javascript
复制
  browserSync : {
        dev : {
            options : {
                files: [root+'style.css',
                        root+'js/**/*.js',
                        root+'**/*.php'],
                watchTask: true,
                debugInfoe: true,
                logConnections: true,
                notify: true,
                proxy: "localhost/www/wordpress",
            }
        }
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29196553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档