{"id":24983716,"url":"https://github.com/posthtml/grunt-posthtml","last_synced_at":"2025-04-19T16:40:01.790Z","repository":{"id":39786883,"uuid":"46132813","full_name":"posthtml/grunt-posthtml","owner":"posthtml","description":"PostHMTL Grunt Plugin","archived":false,"fork":false,"pushed_at":"2023-03-04T02:40:16.000Z","size":567,"stargazers_count":4,"open_issues_count":5,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T21:06:03.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-11-13T16:16:36.000Z","updated_at":"2021-10-04T06:21:41.000Z","dependencies_parsed_at":"2023-01-25T04:45:16.474Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/grunt-posthtml","commit_stats":{"total_commits":71,"total_committers":4,"mean_commits":17.75,"dds":0.3098591549295775,"last_synced_commit":"e5e229fe07468062d554c73c12e70a1ed01e6fec"},"previous_names":["tcotton/grunt-posthtml"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fgrunt-posthtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fgrunt-posthtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fgrunt-posthtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fgrunt-posthtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/grunt-posthtml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248671168,"owners_count":21143044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T09:20:34.586Z","updated_at":"2025-04-19T16:40:01.773Z","avatar_url":"https://github.com/posthtml.png","language":"HTML","readme":"# grunt-posthtml  \n\n[![Travis Build Status](https://img.shields.io/travis/posthtml/grunt-posthtml/master.svg?style=flat-square\u0026label=unix)](https://travis-ci.org/posthtml/grunt-posthtml)[![node](https://img.shields.io/node/v/grunt-posthtml.svg?style=flat-square)]()[![npm version](https://img.shields.io/npm/v/grunt-posthtml.svg?style=flat-square)](https://www.npmjs.com/package/grunt-posthtml)\n\n\u003e [PostHTML](https://github.com/posthtml/posthtml) Grunt Plugin\n\n## Getting Started\nThis plugin requires Grunt `~0.4.5`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-posthtml --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-posthtml');\n```\n\n## The \"posthtml\" task\n\ngrunt-posthtml is a Grunt wrapper for the [PostHTML plugin](https://github.com/posthtml/posthtml)\n\n### Overview\nIn your project's Gruntfile, add a section named `posthtml` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  posthtml: {\n    options: {\n      // Task-specific options go here.\n    },\n    your_target: {\n      // Target-specific file lists and/or options go here.\n    },\n  },\n});\n```\n\nHere is an example of a configuration with three different plugins:\n\n```js\n  posthtml: {\n      options: {\n        use: [\n          require('posthtml-head-elements')({headElements: 'test/config/head.json'}),\n          require('posthtml-doctype')({doctype: 'HTML 5'}),\n          require('posthtml-include')({encoding: 'utf-8'})\n        ]\n      },\n      build: {\n        files: [{\n          expand: true,\n          dot: true,\n          cwd: 'test/html/',\n          src: ['*.html'],\n          dest: 'test/tmp/'\n        }]\n      }\n    }\n```\n\nAlternatively you can use static mapping if you only want to access a single file:\n\n```js\n posthtml: {\n      options: {\n        use: [\n          require('posthtml-head-elements')({headElements: 'test/config/head.json'}),\n          require('posthtml-doctype')({doctype: 'HTML 5'}),\n          require('posthtml-include')({encoding: 'utf-8'})\n        ]\n      },\n      single: {\n        files: [\n          {src: 'test/html2/single.html', dest: 'test/tmp/single.html'}\n        ]\n      }\n    },\n```\n\nIf you are using template strings to add a file path to a PostHTML plugin, then you will need to resolve the path in your Gruntfile configuration. As an example, instead of using this configuration:\n\n```js\n posthtml: {\n     options: {\n         use: [\n             require('posthtml-head-elements')({\n                 headElements: '\u003c%= yeoman.dist %\u003e/config/head_elements.json'\n             }),\n             require('posthtml-doctype')({\n                 doctype: 'HTML 5'\n             })\n         ]\n     },\n     build: {\n         files: [{\n             src: '\u003c%= yeoman.dist %\u003e/index.html',\n             dest: '\u003c%= yeoman.dist %\u003e/index.html'\n         }]\n     }\n }\n```\n\nYou will need to write the path like this:\n\n```js\nposthtml: {\n    options: {\n        use: [\n            require('posthtml-head-elements')({\n                headElements: path.resolve(__dirname, yeomanConfig.app) + '/config/head_elements.json'\n            }),\n            require('posthtml-doctype')({\n                doctype: 'HTML 5'\n            })\n        ]\n    },\n    build: {\n        files: [{\n            src: '\u003c%= yeoman.dist %\u003e/index.html',\n            dest: '\u003c%= yeoman.dist %\u003e/index.html'\n        }]\n    }\n```\n\n### Options\n\nApart from 'use', which is an array of PostHTML plugins, the others options are singleTags, closingSingleTag, skipParse and sync. The values and purpose of these options is exactly the same as in the parent [PostHTML plugin](https://github.com/posthtml/posthtml#options)\n\n## Release History\n * 2015-11-26   v0.3.0          First release on npm.com\n \n * 2015-11-26   v0.1.2-beta.0   Initial release\n \n * 2018-05-09   v1.0.0          Updated all dependencies, devDependencies and peerDependencies\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fgrunt-posthtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fgrunt-posthtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fgrunt-posthtml/lists"}