-
Notifications
You must be signed in to change notification settings - Fork 213
Allow passing html-template options for each entry in 'mains' #865
Comments
I like the approach, but would probably hope for a flatter structure rather than nesting in an |
By default `html-loader@0.x` has a default `attrs` of `['img:src']`, which means only `<img src="...">` tags are followed when parsing the HTML: https://github.com/webpack-contrib/html-loader/blob/v0.5.5/README.md#usage https://github.com/webpack-contrib/html-loader/blob/v0.5.5/index.js#L29 With this change, favicons are included too, and have all the benefits of being included in the webpack build - such as being being inlined by url-loader (if small enough), or else being copied to the output directory automatically and given hashed filenames. This matches the default that will be used in `html-loader` v1.0.0: webpack-contrib/html-loader#17 ...and saves projects from having to resort to the manual Neutrino API to adjust the options used by `html-loader` (see #865).
like this |
This adds support for defining each entry point in `mains` as an object, where the path to the entry point is now defined under an `entry` property, and any other properties can be used by presets for page-specific options. (The short form using a string is still supported.) In the case of `@neutrinojs/web` (and presets that inherit from it), these additional properties are then used to override the options passed to `html-webpack-plugin`, allowing for page-specific customisation of the generated HTML template. For example: ``` module.exports = { options: { mains: { index: { entry: './index', // Options here take priority over the preset's `html` options below. title: 'Site Homepage', }, admin: { entry: './admin', title: 'Admin Dashboard', }, account: { entry: './user', inject: true, template: './my-custom-template.html', }, } }, use: ['@neutrinojs/web', { // Customise the defaults used for all pages. html: { minify: false, } }] } ``` For a list of the available `html-webpack-plugin` options, see: https://github.com/jantimon/html-webpack-plugin#options Fixes #865.
Exactly what I need, but if I use the |
@thany additional properties for each main are passed directly to If you are building your own templates and want access to those, they should be available as It sounds like you're trying to use them in your entry point, but this issue/PR solely deals with passing options to As for setting things on |
I must say I'm not that savvy with neutrino/webpack, but you're absolutely right. I got around it, and this was just a kick in the right direction. Thanks! |
For multi-entrypoint projects, it's possible to add multiple entries to the Neutrino
mains
option, like so:However in the web preset, the same
html
options property is used for each, which means there is no way to give the pages different titles or vary the template used.For mozilla/treeherder's Neutrino v8 WIP, I'm currently working around this with:
...but it seems likely that anyone using Neutrino's multi-entrypoint support is having to do something similar - so perhaps should be supported natively.
One way of doing so might be to permit the main's value to be an object (whilst still supporting the string form for the simple case). ie:
@mozilla-neutrino/core-contributors - thoughts?
The text was updated successfully, but these errors were encountered: