Skip to content

Commit

Permalink
refactor: move placeholder regexp to another PR
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Apr 20, 2019
1 parent 62ecfe9 commit ef33e7d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Expand Up @@ -16,7 +16,6 @@ const pluginName = 'mini-css-extract-plugin';
const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/i;
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/i;
const REGEXP_NAME = /\[name\]/i;
const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/g;
const DEFAULT_FILENAME = '[name].css';

class CssDependency extends webpack.Dependency {
Expand Down Expand Up @@ -131,9 +130,12 @@ class MiniCssExtractPlugin {

if (!this.options.chunkFilename) {
const { filename } = this.options;
const hasName = filename.includes('[name]');
const hasId = filename.includes('[id]');
const hasChunkHash = filename.includes('[chunkhash]');

// Anything changing depending on chunk is fine
if (REGEXP_PLACEHOLDERS.test(filename)) {
if (hasChunkHash || hasName || hasId) {
this.options.chunkFilename = filename;
} else {
// Elsewise prefix '[id].' in front of the basename to make it changing
Expand Down

0 comments on commit ef33e7d

Please sign in to comment.