/*! * @nuxt/webpack v2.13.3 (c) 2016-2020 * - All the amazing contributors * Released under the MIT License. * Website: https://nuxtjs.org */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } const path = _interopDefault(require('path')); const pify = _interopDefault(require('pify')); const webpack = require('webpack'); const webpack__default = _interopDefault(webpack); const Glob = _interopDefault(require('glob')); const webpackDevMiddleware = _interopDefault(require('webpack-dev-middleware')); const webpackHotMiddleware = _interopDefault(require('webpack-hot-middleware')); const consola = _interopDefault(require('consola')); const utils = require('@nuxt/utils'); const MFS = _interopDefault(require('memory-fs')); const querystring = _interopDefault(require('querystring')); const HtmlWebpackPlugin = _interopDefault(require('html-webpack-plugin')); const BundleAnalyzer = _interopDefault(require('webpack-bundle-analyzer')); const OptimizeCSSAssetsPlugin = _interopDefault(require('optimize-css-assets-webpack-plugin')); const FriendlyErrorsWebpackPlugin = _interopDefault(require('@nuxt/friendly-errors-webpack-plugin')); const hash = _interopDefault(require('hash-sum')); const EventEmitter = _interopDefault(require('events')); const TimeFixPlugin = _interopDefault(require('time-fix-plugin')); const VueLoader = _interopDefault(require('vue-loader')); const ExtractCssChunksPlugin = _interopDefault(require('extract-css-chunks-webpack-plugin')); const HardSourcePlugin = _interopDefault(require('hard-source-webpack-plugin')); const TerserWebpackPlugin = _interopDefault(require('terser-webpack-plugin')); const WebpackBar = _interopDefault(require('webpackbar')); const env = _interopDefault(require('std-env')); const semver = _interopDefault(require('semver')); const threadLoader = require('thread-loader'); const fs = _interopDefault(require('fs')); const createResolver = _interopDefault(require('postcss-import-resolver')); const nodeExternals = _interopDefault(require('webpack-node-externals')); class AsyncMFS extends MFS {} const syncRegex = /Sync$/; const propsToPromisify = Object.getOwnPropertyNames(MFS.prototype).filter(n => syncRegex.test(n)); for (const prop of propsToPromisify) { const asyncProp = prop.replace(syncRegex, ''); const origAsync = AsyncMFS.prototype[asyncProp]; AsyncMFS.prototype[asyncProp] = function (...args) { // Callback support for webpack if (origAsync && args.length && typeof args[args.length - 1] === 'function') { return origAsync.call(this, ...args) } try { return Promise.resolve(MFS.prototype[prop].call(this, ...args)) } catch (error) { return Promise.reject(error) } }; } 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; } } }); }); }); } } /* * 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 */ const assetsMap = {}; const watcher = new EventEmitter(); 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.tapAsync(ID, (data, cb) => { // get stats, write to disk this.assets = { name: data.plugin.options.filename, content: data.bodyTags }; cb(); }); }); } applyModern (compiler) { const ID = 'nuxt-modern-bundle'; compiler.hooks.compilation.tap(ID, (compilation) => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(ID, async (data, cb) => { // use