L
L
Limpus2019-03-02 00:05:55
Grunt.js
Limpus, 2019-03-02 00:05:55

Why is Grunt's posthtml-include Plugin not working?

Why is Grunt's posthtml-include Plugin not working?
File: package.json

{
  "name": "test",
  "version": "1.0.0",
  "devDependencies": {
    "grunt": "^1.0.3",
    "grunt-browser-sync": "^2.2.0",
    "grunt-contrib-imagemin": "^3.1.0",
    "grunt-contrib-less": "^2.0.0",
    "grunt-contrib-watch": "^1.1.0",
    "grunt-csso": "^2.2.4",
    "grunt-cwebp": "^2.1.1",
    "grunt-newer": "^1.3.0",
    "grunt-postcss": "^0.9.0",
    "grunt-posthtml": "^0.5.0",
    "grunt-rigger": "^0.6.0",
    "grunt-svgstore": "^2.0.0",
    "load-grunt-tasks": "^4.0.0",
    "posthtml-include": "^1.2.0"
  },
  "dependencies": {
    "autoprefixer": "^9.4.9",
    "cssnano": "^4.1.10",
    "pixrem": "^5.0.0"
  }
}

File: Gruntfile.js
posthtml: {
        options: {
          use: [
            require('posthtml-include')({ root: './', encoding: 'utf-8' })
          ]
        },
        build: {
          files: [
            {
              src: ["src/html/index.html"],
              expand: true
            }
          ]
        }
      }

File: index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Test</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/library/normalize.css"rel="stylesheet">
    <link href="css/all.min.css" rel="stylesheet">
  </head>
  <body>

  <include src="header.html"></include>

  </body>
</html>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question