Support for specifying plugins in Array #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
I got a build error when using the followings.
The error is as follows.
Cause
In my
nuxt.config.js
, I was specifyingbuild.postcss.plugins
as an array.On the other hand, @nuxt/postcss8 uses object as value of
build.postcss.plugins
.My
nuxt.config.js
is like the following.@nuxt/postcss8
usesdefu
to merge the settings.When
defu
merges an object against an array, it uses the array index as the object's key.Thus,
defu
would buildbuild.postcss.plugins
like the following.You can reproduce this by checking out a57775a and then running
yarn dev
.Solution
Select the format corresponding to
build.postcss.plugins
as defined innuxt.config.js
. Ifbuild.postcss.plugins
is an array, use array format, if it is an object, use object format to merge (06f3bee).Test
yarn test
yarn dev
yarn dev:legacy
Notes.
Jest
.src/index.ts
and run the test,TypeError: defu_1.default is not a function
gotten.dist/index.js
in the test.dev:legacy
because we wanted to check the behavior with two differentnuxt.config.js
.postcss-loader
deprecates the object format, I named the configuration using the object format aslegacy
.