• 前端切页面 架构配置 node npm grunt grunt合并HTML必看


    快速搭建前端开发环境

    1.npm包依赖

    {
      "name": "demo",
      "version": "1.0.0",
      "description": "demo",
      "main": "index.js",
      "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
      },
      "author": "",
      "devDependencies": {
        "grunt": "^0.4.5",
        "grunt-contrib-concat": "^0.5.1",
        "grunt-contrib-watch": "^0.6.1",
        "grunt-html-build": "^0.5.3"
      },
      "license": "ISC"
    }

    2.grunt 配置

    module.exports = function(grunt) {
    
        // Project configuration.
        grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            fixturesPath: "html",
            htmlbuild: {
                index: {
                    src: './html/src/*.html',
                    dest: './html/',
                    options: {
                        beautify: true,
                        sections: {
                            layout: {
                                header: '<%= fixturesPath %>/layout/header.html',
                                footer: '<%= fixturesPath %>/layout/footer.html',
                                left: '<%= fixturesPath %>/layout/left.html'
                            }
                        },
                        data: {
                            // Data to pass to templates
                            version: "0.1.0",
                            title: "test",
                        }
                    }
                }
            },
            watch: {
                js: {
                    files: ['html/**/*.html'],
                    tasks: ['htmlbuild']
                }
            }
        });
        // 加载包含 "uglify" 任务的插件。
    
        grunt.loadNpmTasks('grunt-html-build');
        grunt.loadNpmTasks('grunt-contrib-watch');
    
        // 默认被执行的任务列表。
        grunt.registerTask('default', ['htmlbuild', 'watch']);
    
    };

    3.官方参考文章

    https://github.com/spatools/grunt-html-build

  • 相关阅读:
    Problem F
    Problem L
    Problem L
    Problem B
    Problem B
    读书笔记-Java设计模式
    读书笔记-内存初始化和清理
    读书笔记- 一切都是对象
    Android多点触控技术实战,自由地对图片进行缩放和移动
    Native开发与JNI机制详解
  • 原文地址:https://www.cnblogs.com/lmw425317/p/5317867.html
Copyright © 2020-2023  润新知