How to use the html-webpack-plugin.__expression function in html-webpack-plugin

To help you get started, we’ve selected a few html-webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github egoist / poi / packages / poi / lib / plugins / config-app.js View on Github external
chunks: 'initial'
          },
          common: {
            name: `chunk-common`,
            minChunks: 2,
            priority: -20,
            chunks: 'initial',
            reuseExistingChunk: true
          }
        }
      })
    }

    // Generate HTML files for each entry
    const HtmlPlugin = require('html-webpack-plugin')
    HtmlPlugin.__expression = `require('html-webpack-plugin')`

    for (const entryName of Object.keys(api.config.pages)) {
      const page = Object.assign(
        {
          template: api.config.defaultTemplate,
          title: api.projectPkg.data.name || 'Poi App',
          filename: `${entryName}.html`
        },
        api.config.pages[entryName]
      )

      // Generate html file for this entry
      page.template = api.resolveBaseDir(page.template)
      if (!fs.existsSync(page.template)) {
        page.template = path.join(__dirname, '../default-template.html')
      }
github egoist / poi / core / poi / lib / plugins / config-html.js View on Github external
api.hook('createWebpackChain', config => {
    // No need to generate HTML files for CJS format
    // For UMD format it still might be useful since you can use to test if your library works
    if (api.config.output.format === 'cjs') return

    const HtmlPlugin = require('html-webpack-plugin')
    HtmlPlugin.__expression = `require('html-webpack-plugin')`

    // Split vendors and common chunks
    if (api.mode === 'production' && api.config.output.format === 'iife') {
      config.optimization.splitChunks({
        cacheGroups: {
          vendors: {
            name: `chunk-vendors`,
            test: /[\\/]node_modules[\\/]/,
            priority: -10,
            chunks: 'initial'
          },
          common: {
            name: `chunk-common`,
            minChunks: 2,
            priority: -20,
            chunks: 'initial',