Skip to content

Commit aff77eb

Browse files
refactor: code (webpack-contrib#23)
1 parent bfb75a7 commit aff77eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import os from 'os';
22
import crypto from 'crypto';
33

44
import { SourceMapConsumer } from 'source-map';
5-
import { SourceMapSource, RawSource } from 'webpack-sources';
65
import RequestShortener from 'webpack/lib/RequestShortener';
7-
import {
6+
import webpack, {
87
ModuleFilenameHelpers,
98
SourceMapDevToolPlugin,
109
version as webpackVersion,
@@ -21,6 +20,11 @@ import { minify as minifyFn } from './minify';
2120

2221
const warningRegex = /\s.+:+([0-9]+):+([0-9]+)/;
2322

23+
// webpack 5 exposes the sources property to ensure the right version of webpack-sources is used
24+
const { SourceMapSource, RawSource } =
25+
// eslint-disable-next-line global-require
26+
webpack.sources || require('webpack-sources');
27+
2428
class CssMinimizerPlugin {
2529
constructor(options = {}) {
2630
validateOptions(schema, options, {

0 commit comments

Comments
 (0)