From d42bc5a0a689c584e1691e8887e51e6ca14b4a73 Mon Sep 17 00:00:00 2001 From: cap-Bernardito Date: Fri, 21 Aug 2020 20:34:32 +0300 Subject: [PATCH] refactor: code --- src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index dea4beb..84ba65a 100644 --- a/src/index.js +++ b/src/index.js @@ -2,9 +2,8 @@ import os from 'os'; import crypto from 'crypto'; import { SourceMapConsumer } from 'source-map'; -import { SourceMapSource, RawSource } from 'webpack-sources'; import RequestShortener from 'webpack/lib/RequestShortener'; -import { +import webpack, { ModuleFilenameHelpers, SourceMapDevToolPlugin, version as webpackVersion, @@ -21,6 +20,11 @@ import { minify as minifyFn } from './minify'; const warningRegex = /\s.+:+([0-9]+):+([0-9]+)/; +// webpack 5 exposes the sources property to ensure the right version of webpack-sources is used +const { SourceMapSource, RawSource } = + // eslint-disable-next-line global-require + webpack.sources || require('webpack-sources'); + class CssMinimizerPlugin { constructor(options = {}) { validateOptions(schema, options, {