Skip to content

Add outputPath as plugin option, override conditional checks #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export default {
path: path.join(__dirname, './dist')
},
plugins: [
new WriteFilePlugin()
new WriteFilePlugin(
outputPath: path.join(__dirname, './dist')
)
],
// ...
}
Expand Down
5 changes: 3 additions & 2 deletions sandbox/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var devServer,

webpack = require('webpack');
path = require('path');
WriteFileWebpackPlugin = require('./../dist').default;
WriteFileWebpackPlugin = require('./../dist');

devServer = {
outputPath: path.join(__dirname, './dist'),
Expand Down Expand Up @@ -36,7 +36,8 @@ module.exports = {
},
plugins: [
new WriteFileWebpackPlugin({
test: /foo/
test: /foo/,
outputPath: devServer.outputPath,
})
]
};
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export default (userOptions: UserOptionsType = {}): Object => {
return false;
}

if (_.has(compiler, 'options.output.path') && compiler.options.output.path !== '/') {
outputPath = compiler.options.output.path;
if (options.outputPath) {
outputPath = options.outputPath;
Copy link

@jkomusin jkomusin Apr 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will cause the plugin to fail if no outputPath option is specified (see the check below this). For backwards compatibility it may want to fall back to the original output.path of the compiler.

}

if (!outputPath) {
Expand Down