Skip to content

How to add attribute to script tags? #1766

Answered by rschristian
micahjon asked this question in Q&A
Discussion options

You must be logged in to vote

I'll go through why this doesn't work first, feel free to skip to the end to get my recommended solution though.

First things first, yes, that is a valid way to add a plugin to the Webpack config. However, Preact-CLI has two distinct builds: the server, bundling content for execution in Node to prerender your app, and the client, which is the stuff destined for the browser. As such, html-webpack-plugin is not ran on the server builds (as HTML is strictly for the browser). We'd adjust your config to look like the following:

// preact.config.js
import MyPlugin from './webpack-plugin.js';

export default function (config, env, helpers, options) {
  if (!env.isServer) {
      config.plugins.push

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@micahjon
Comment options

@rschristian
Comment options

@rschristian
Comment options

Answer selected by micahjon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants