{"id":13718742,"url":"https://github.com/vseventer/hugo-webpack-boilerplate","last_synced_at":"2025-05-07T10:33:55.140Z","repository":{"id":142799918,"uuid":"83586439","full_name":"vseventer/hugo-webpack-boilerplate","owner":"vseventer","description":"Hugo and Webpack boilerplate.","archived":true,"fork":false,"pushed_at":"2017-09-30T17:51:36.000Z","size":23,"stargazers_count":44,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T00:39:34.160Z","etag":null,"topics":["boilerplate","hugo","hugo-boilerplate","webpack","webpack-boilerplate"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vseventer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-01T18:20:14.000Z","updated_at":"2024-09-04T05:49:27.000Z","dependencies_parsed_at":"2023-05-11T07:30:42.709Z","dependency_job_id":null,"html_url":"https://github.com/vseventer/hugo-webpack-boilerplate","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Fhugo-webpack-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Fhugo-webpack-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Fhugo-webpack-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Fhugo-webpack-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vseventer","download_url":"https://codeload.github.com/vseventer/hugo-webpack-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252859987,"owners_count":21815439,"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":["boilerplate","hugo","hugo-boilerplate","webpack","webpack-boilerplate"],"created_at":"2024-08-03T01:00:36.866Z","updated_at":"2025-05-07T10:33:54.003Z","avatar_url":"https://github.com/vseventer.png","language":"JavaScript","funding_links":[],"categories":["Starters"],"sub_categories":["Non-Official"],"readme":"# hugo-webpack-boilerplate\n\u003e [Hugo](https://gohugo.io) and [Webpack](https://webpack.js.org/) boilerplate.\n\n## Install\n`npm install hugo-webpack-boilerplate`\n\n## Usage\nWe all love [Hugo](https://gohugo.io), but it is cumbersome to use anything beyond simple HTML, CSS, and JavaScript. What about LESS/SASS, ES6, minification, tree-shaking, or asset revving? Sure, you can roll your own, but these are all things [Webpack](https://webpack.js.org/) was designed for.\n\nGiven Webpack typically takes a JavaScript file as entry point, but Hugo generates mostly HTML, it is quite complicated to come up with a useful workflow. This repository is an attempt to bind Hugo and Webpack together, giving Webpack full power over the files generated by Hugo. You can continue to use Hugo as you normally would, but enjoy the additional benefits of Webpack.\n\nIn your `webpack.config.js`, use:\n\n```js\n// Exports.\nmodule.exports = require('hugo-webpack-boilerplate');\n```\n\nAlternatively, if you are not using Hugo’s default `publishDir`, use:\n\n```js\n// Exports.\nmodule.exports = require('hugo-webpack-boilerplate').fromConfig({\n  hugoPublishDir: 'hugo-publish-dir', // Defaults to public/\n  outDir: 'my-publish-dir' // Defaults to dist/\n});\n```\n\nCurrently, only the Hugo `publishDir` and `outDir` are customizable. Over time, this module will be extended to allow further customizations.\n\n### Example 1\nThis example considers a simple HTML file, a SASS stylesheet, image, and ES6 JavaScript file. The assets live under `static/` (Hugo’s default), so for example, the image should be located at `static/img/example.jpg`. Note the usage of `~` (tilde), which will make sure Webpack can find the assets. Also, this module relies on [interpolation by the `html-loader`](https://github.com/webpack-contrib/html-loader#interpolation), so make sure to import assets using `require`, as shown below.\n\nWhen running `webpack -p`, Webpack will take all these assets, [`optimize-minimize`](https://webpack.js.org/guides/production-build/) them, and put them in the `dist/` folder. Alternatively, you can run `webpack -w` to start the local development server.\n\n#### Input\n`layouts/index.html`\n```html\n\u003c!doctype html\u003e\n\u003clink rel=\"stylesheet\" href=\"~scss/style.scss\" /\u003e\n\u003ctitle\u003eThis is an example\u003c/title\u003e\n\u003cimg src=\"${require(`~img/example.jpg`)}\" /\u003e\n\u003cscript src=\"${require(`~js/script.js`)}\"\u003e\u003c/script\u003e\n```\n\n#### Output\n`dist/index.html`\n```html\n\u003c!doctype html\u003e\n\u003clink rel=\"stylesheet\" href=\"/css/style.hash.css\" /\u003e\n\u003ctitle\u003eThis is an example\u003c/title\u003e\n\u003cimg src=\"/img/example.hash.jpg\" /\u003e\n\u003cscript src=\"/js/script.hash.js\"\u003e\u003c/script\u003e\n```\n\n## FAQ\n* I’m getting UnCSS errors, like `Could not load script: \"file:///~js/script.js\"`?\n\nUnCSS attempts to load scripts from disk, which will not work if they are referenced by `~`. The error is however non-blocking, and the UnCSS output is still useful. Just note that any selectors dynamically added will not be in the resulting stylesheet.\n\n* The watching task causes Webpack to continuously reload?\n\nThere is a [bug in watchpack](https://github.com/webpack/watchpack/issues/25) causing the watcher to reload the same files over and over until the files settle. Apart from being an inconvenience, it does not affect your bundles.\n\n* Can I use configure or add custom Webpack loaders or plugins?\n\nRight now, no, there is no way to do this. Feel free to submit an issue or PR if you’d like to see any additions. It should be pretty simple to add this to the `fromConfig` function in `src/index.js`.\n\n## Changelog\nSee the [CHANGELOG](./CHANGELOG.md) for a list of changes.\n\n## License\n    The MIT License (MIT)\n\n    Copyright (c) 2017 Mark van Seventer\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy of\n    this software and associated documentation files (the \"Software\"), to deal in\n    the Software without restriction, including without limitation the rights to\n    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n    the Software, and to permit persons to whom the Software is furnished to do so,\n    subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n    FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n    COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n    IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvseventer%2Fhugo-webpack-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvseventer%2Fhugo-webpack-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvseventer%2Fhugo-webpack-boilerplate/lists"}