Skip to content

Commit ebbef87

Browse files
authored
Merge pull request webpack-contrib#101 from ertrzyiks/handle-lack-of-compilation-object
Gracefully handle lack of compilation object
2 parents d767948 + b236155 commit ebbef87

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@ module.exports = function (source, map) {
8383
}
8484

8585
// Allow plugins to add or remove postcss plugins
86-
plugins = this._compilation.applyPluginsWaterfall(
87-
'postcss-loader-before-processing',
88-
[].concat(plugins),
89-
params
90-
);
86+
if ( this._compilation ) {
87+
plugins = this._compilation.applyPluginsWaterfall(
88+
'postcss-loader-before-processing',
89+
[].concat(plugins),
90+
params
91+
);
92+
} else {
93+
loader.emitWarning(
94+
'this._compilation is not available thus ' +
95+
'`postcss-loader-before-processing` is not supported'
96+
);
97+
}
9198

9299
postcss(plugins).process(source, opts)
93100
.then(function (result) {

0 commit comments

Comments
 (0)