Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
}
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',