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,
standalone: false,
publicPath: '/_nuxt/',
serverURLPolyfill: 'url',
filenames: {
// { isDev, isClient, isServer }
app: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[contenthash].js',

View File

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

View File

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

View File

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