diff --git a/packages/nuxt3/src/webpack/configs/client.ts b/packages/nuxt3/src/webpack/configs/client.ts index 5755f36a28..2a004e01c2 100644 --- a/packages/nuxt3/src/webpack/configs/client.ts +++ b/packages/nuxt3/src/webpack/configs/client.ts @@ -1,9 +1,7 @@ import path from 'path' import querystring from 'querystring' import webpack from 'webpack' -import HTMLPlugin from 'html-webpack-plugin' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' -import CorsPlugin from '../plugins/vue/cors' import { applyPresets, WebpackConfigContext } from '../utils/config' import { nuxt } from '../presets/nuxt' @@ -17,8 +15,7 @@ export function client (ctx: WebpackConfigContext) { clientOptimization, clientDevtool, clientPerformance, - clientHMR, - clientHTML + clientHMR ]) } @@ -83,20 +80,6 @@ function clientOptimization (ctx: WebpackConfigContext) { // TODO: Improve optimization.splitChunks.cacheGroups } -function clientHTML (ctx: WebpackConfigContext) { - const { options, config } = ctx - - // Generate output HTML for SSR - config.plugins.push( - new HTMLPlugin({ - filename: '../server/index.ssr.html', - template: options.documentPath, - minify: options.build.html.minify as any, - inject: false // Resources will be injected using bundleRenderer - }) - ) -} - function clientPlugins (ctx: WebpackConfigContext) { const { options, config } = ctx diff --git a/packages/nuxt3/src/webpack/plugins/vue/cors.ts b/packages/nuxt3/src/webpack/plugins/vue/cors.ts deleted file mode 100644 index 60b680bed9..0000000000 --- a/packages/nuxt3/src/webpack/plugins/vue/cors.ts +++ /dev/null @@ -1,26 +0,0 @@ -import HtmlWebpackPlugin from 'html-webpack-plugin' - -export default class CorsPlugin { - constructor ({ crossorigin }) { - this.crossorigin = crossorigin - } - - apply (compiler) { - const ID = 'vue-cors-plugin' - compiler.hooks.compilation.tap(ID, (compilation) => { - HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tap(ID, (data) => { - if (!this.crossorigin) { - return - } - [...data.headTags, ...data.bodyTags].forEach((tag) => { - if (['script', 'link'].includes(tag.tagName)) { - if (tag.attributes) { - tag.attributes.crossorigin = this.crossorigin - } - } - }) - return data - }) - }) - } -} diff --git a/packages/nuxt3/src/webpack/plugins/vue/modern.ts b/packages/nuxt3/src/webpack/plugins/vue/modern.ts deleted file mode 100644 index 855380f7ba..0000000000 --- a/packages/nuxt3/src/webpack/plugins/vue/modern.ts +++ /dev/null @@ -1,130 +0,0 @@ -/* -* This file is based on @vue/cli-service (MIT) ModernModePlugin -* https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js -*/ - -import EventEmitter from 'events' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import { safariNoModuleFix } from 'src/utils' - -const assetsMap = {} -const watcher = new EventEmitter() - -export default class ModernModePlugin { - constructor ({ targetDir, isModernBuild, noUnsafeInline }) { - this.targetDir = targetDir - this.isModernBuild = isModernBuild - this.noUnsafeInline = noUnsafeInline - } - - apply (compiler) { - if (!this.isModernBuild) { - this.applyLegacy(compiler) - } else { - this.applyModern(compiler) - } - } - - get assets () { - return assetsMap - } - - set assets ({ name, content }) { - assetsMap[name] = content - watcher.emit(name) - } - - getAssets (name) { - return new Promise((resolve) => { - const asset = this.assets[name] - if (asset) { - return resolve(asset) - } - return watcher.once(name, () => { - const asset = this.assets[name] - return asset && resolve(asset) - }) - }) - } - - applyLegacy (compiler) { - const ID = 'nuxt-legacy-bundle' - compiler.hooks.compilation.tap(ID, (compilation) => { - HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tap(ID, (data) => { - // get stats, write to disk - this.assets = { - name: data.plugin.options.filename, - content: data.bodyTags - } - return data - }) - }) - } - - applyModern (compiler) { - const ID = 'nuxt-modern-bundle' - compiler.hooks.compilation.tap(ID, (compilation) => { - HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapPromise(ID, async (data) => { - // use