Skip to content

Commit

Permalink
fix(options): use filename mutated after instantiation (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbennett-stacki authored and evilebottnawi committed Jul 19, 2019
1 parent 87d929e commit 0bacfac
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MiniCssExtractPlugin {
this.options = Object.assign(
{
filename: DEFAULT_FILENAME,
moduleFilename: () => options.filename || DEFAULT_FILENAME,
moduleFilename: () => this.options.filename || DEFAULT_FILENAME,
ignoreOrder: false,
},
options
Expand Down
4 changes: 4 additions & 0 deletions test/cases/moduleFilenameMutableFilename/expected/mutated.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: palegreen;
}

1 change: 1 addition & 0 deletions test/cases/moduleFilenameMutableFilename/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './style.css';
3 changes: 3 additions & 0 deletions test/cases/moduleFilenameMutableFilename/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: palegreen;
}
27 changes: 27 additions & 0 deletions test/cases/moduleFilenameMutableFilename/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const Self = require('../../../');

module.exports = {
entry: {
main: './index.js',
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, 'css-loader'],
},
],
},
output: {
filename: '[name].js',
},
plugins: [
(() => {
const self = new Self({ filename: 'constructed.css' });

self.options.filename = 'mutated.css';

return self;
})(),
],
};

0 comments on commit 0bacfac

Please sign in to comment.