Skip to content

addWorkerLoader#69

Merged
FezVrasta merged 2 commits into
arackaf:masterfrom
liyuanqiu:master
Mar 13, 2019
Merged

addWorkerLoader#69
FezVrasta merged 2 commits into
arackaf:masterfrom
liyuanqiu:master

Conversation

@liyuanqiu

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread index.js
const addWorkerLoader = (loaderOptions = {}) => config => {
const loaders = config.module.rules.find(rule => Array.isArray(rule.oneOf)).oneOf;

loaders.splice(loaders.length - 1, 0, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is this splice doing here? Adding to the end of the array the new object?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keep the same behavior with addLessLoader.

  // Insert less-loader as the penultimate item of loaders (before file-loader)
  loaders.splice(loaders.length - 1, 0, {
    test: lessRegex,
    exclude: lessModuleRegex,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll give an online example later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh ok I see, thanks for the explanation!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I found some error to fix. You are right, the loader shouldn't be added as the penultimate item. This merge should be reverted.

Here is an example:
https://github.com/liyuanqiu/addWorkerLoaderDemo

@FezVrasta FezVrasta merged commit e8d7727 into arackaf:master Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants