3
3
import webpack from 'webpack' ;
4
4
import sources from 'webpack-sources' ;
5
5
6
+ import CssDependency from './CssDependency' ;
7
+
6
8
const { ConcatSource, SourceMapSource, OriginalSource } = sources ;
7
9
const {
8
10
Template,
@@ -19,27 +21,6 @@ const REGEXP_NAME = /\[name\]/i;
19
21
const REGEXP_PLACEHOLDERS = / \[ ( n a m e | i d | c h u n k h a s h ) \] / g;
20
22
const DEFAULT_FILENAME = '[name].css' ;
21
23
22
- class CssDependency extends webpack . Dependency {
23
- constructor (
24
- { identifier, content, media, sourceMap } ,
25
- context ,
26
- identifierIndex
27
- ) {
28
- super ( ) ;
29
-
30
- this . identifier = identifier ;
31
- this . identifierIndex = identifierIndex ;
32
- this . content = content ;
33
- this . media = media ;
34
- this . sourceMap = sourceMap ;
35
- this . context = context ;
36
- }
37
-
38
- getResourceIdentifier ( ) {
39
- return `css-module-${ this . identifier } -${ this . identifierIndex } ` ;
40
- }
41
- }
42
-
43
24
class CssDependencyTemplate {
44
25
apply ( ) { }
45
26
}
@@ -148,30 +129,6 @@ class MiniCssExtractPlugin {
148
129
149
130
apply ( compiler ) {
150
131
compiler . hooks . thisCompilation . tap ( pluginName , ( compilation ) => {
151
- compilation . hooks . normalModuleLoader . tap ( pluginName , ( lc , m ) => {
152
- const loaderContext = lc ;
153
- const module = m ;
154
-
155
- loaderContext [ MODULE_TYPE ] = ( content ) => {
156
- if ( ! Array . isArray ( content ) && content != null ) {
157
- throw new Error (
158
- `Exported value was not extracted as an array: ${ JSON . stringify (
159
- content
160
- ) } `
161
- ) ;
162
- }
163
-
164
- const identifierCountMap = new Map ( ) ;
165
-
166
- for ( const line of content ) {
167
- const count = identifierCountMap . get ( line . identifier ) || 0 ;
168
-
169
- module . addDependency ( new CssDependency ( line , m . context , count ) ) ;
170
- identifierCountMap . set ( line . identifier , count + 1 ) ;
171
- }
172
- } ;
173
- } ) ;
174
-
175
132
compilation . dependencyFactories . set (
176
133
CssDependency ,
177
134
new CssModuleFactory ( )
0 commit comments