There is no comma because this is all just a value. What is happening there is not the statement of a function, it is the call of a function.
That:
module.exports = {
plugins: [
require("postcss-uncss")({
html: [
'./index.html'
]
})
]
}
That’s the equivalent of:
const postcssUncss = require("postcss-uncss");
const postcssPlugin = postcssUncss({ html: ['./index.html'] });
module.exports = {
plugins: [postcssPlugin]
}
You are importing the module postcss-uncss
, that is exposing a function, and immediately you invoke the function by passing the parameter { html: ['./index.html'] }
. Her return is the value passed to the array plugins
.
It is important to remember, although it works, this is probably not a good idea, in many languages the import of other files is always done at the beginning of the file, even those that are not mandatory also do this, is a standard adopted by all, not to use this standard, You must have a reason. Also, this form does not allow reuse, if somewhere else you want to use the module, you will have to reimport it, or use the default at the beginning of the file save the module to a variable, and if this is done, can leave the messy code importing only a few modules at the beginning and others not
– Costamilam