fix(webpack): provide global URL and URLSearchParams (#6864)

This commit is contained in:
Pooya Parsa 2020-01-19 09:37:06 +01:00 committed by GitHub
parent 2707bdb37e
commit 00d95903c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -17,6 +17,7 @@ export default () => ({
cache: false, cache: false,
standalone: false, standalone: false,
publicPath: '/_nuxt/', publicPath: '/_nuxt/',
serverURLPolyfill: 'url',
filenames: { filenames: {
// { isDev, isClient, isServer } // { isDev, isClient, isServer }
app: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[contenthash].js', app: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[contenthash].js',

View File

@ -130,6 +130,7 @@ Object {
"profile": false, "profile": false,
"publicPath": "/_nuxt/", "publicPath": "/_nuxt/",
"quiet": true, "quiet": true,
"serverURLPolyfill": "url",
"splitChunks": Object { "splitChunks": Object {
"commons": true, "commons": true,
"layouts": false, "layouts": false,

View File

@ -104,6 +104,7 @@ Object {
"profile": false, "profile": false,
"publicPath": "/_nuxt/", "publicPath": "/_nuxt/",
"quiet": true, "quiet": true,
"serverURLPolyfill": "url",
"splitChunks": Object { "splitChunks": Object {
"commons": true, "commons": true,
"layouts": false, "layouts": false,
@ -458,6 +459,7 @@ Object {
"profile": false, "profile": false,
"publicPath": "/_nuxt/", "publicPath": "/_nuxt/",
"quiet": true, "quiet": true,
"serverURLPolyfill": "url",
"splitChunks": Object { "splitChunks": Object {
"commons": true, "commons": true,
"layouts": false, "layouts": false,

View File

@ -1,6 +1,6 @@
import path from 'path' import path from 'path'
import fs from 'fs' import fs from 'fs'
import webpack from 'webpack' import { DefinePlugin, ProvidePlugin } from 'webpack'
import nodeExternals from 'webpack-node-externals' import nodeExternals from 'webpack-node-externals'
import VueSSRServerPlugin from '../plugins/vue/server' import VueSSRServerPlugin from '../plugins/vue/server'
@ -69,11 +69,19 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
plugins () { plugins () {
const plugins = super.plugins() const plugins = super.plugins()
plugins.push( plugins.push(
new VueSSRServerPlugin({ new VueSSRServerPlugin({ filename: `${this.name}.manifest.json` }),
filename: `${this.name}.manifest.json` new DefinePlugin(this.env())
}),
new webpack.DefinePlugin(this.env())
) )
const { serverURLPolyfill } = this.buildContext.options.build
if (serverURLPolyfill) {
plugins.push(new ProvidePlugin({
URL: [serverURLPolyfill, 'URL'],
URLSearchParams: [serverURLPolyfill, 'URLSearchParams']
}))
}
return plugins return plugins
} }