Skip to content

Commit f8abd09

Browse files
committed
Do not insist on devServer.outputPath (fixes #5)
1 parent 336d126 commit f8abd09

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,20 @@ export default (userOptions = {}) => {
9090
return;
9191
}
9292

93-
if (!compiler.options.devServer.outputPath) {
94-
throw new Error('devServer.outputPath is not defined.');
93+
// https://github.com/gajus/write-file-webpack-plugin/issues/1
94+
if (_.has(compiler, 'options.output.path') && compiler.options.output.path !== path.sep) {
95+
outputPath = compiler.options.output.path;
9596
}
9697

97-
outputPath = compiler.options.devServer.outputPath;
98+
if (!outputPath) {
99+
if (!_.has(compiler, 'options.devServer.outputPath')) {
100+
throw new Error('output.path is not accessible and devServer.outputPath is not defined. Define devServer.outputPath.');
101+
}
102+
103+
outputPath = compiler.options.devServer.outputPath;
104+
}
98105

99-
log('compiler.options.devServer.outputPath is "' + chalk.cyan(compiler.options.devServer.outputPath) + '".');
106+
log('compiler.options.devServer.outputPath is "' + chalk.cyan(outputPath) + '".');
100107

101108
setupStatus = true;
102109

0 commit comments

Comments
 (0)