Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
complex-loader
Advanced tools
Readme
Combine results from multiple loaders into one object.
{
test: /\.md$/,
exclude: /node_modules/,
use: {
loader : `complex-loader`,
options: {
attributes: [
`json-loader`,
`yaml-loader`,
{
loader : `front-matter-loader`,
options: {
onlyAttributes: true,
},
},
],
Component: [
{
loader : `markdown-feat-react-loader`,
options: {
config: require.resolve(`./react-markdown.config.js`),
importImages: true,
}
},
{
loader : `front-matter-loader`,
options: {
onlyBody: true,
},
},
]
},
}
}
Import all desired data about file by one import.
import readme from 'readme.md'
console.log(readme)
/*
{
attributes: {...},
Component: function()
}
*/
There is another similar loader called combine-loader. But it allows you to specify loaders only in a string format. The reason for creating complex-loader
was the support of defining loaders using javascript objects. This means that you can use functions, arrays, objects, and any others javascript entities.
If you are importing a resource from the outside the directory where node_modules have placed, specify loaders absolute paths by using require.resolve
.
[
require.resolve(`json-loader`),
require.resolve(`yaml-loader`)
]
This is because, on the nested level, the paths to the loaders will be resolved relative to the directory in which your file is located.
You can specify as nested loader the same complex-loader
.
{
test: /\.png/,
exclude: /node_modules/,
use: {
loader : `complex-loader`,
options: {
deeper: {
loader: `complex-loader`,
options: {
and: {
loader: `complex-loader`,
options: {
deeper: 'url-loader'
}
}
}
}
}
}
}
// Will give:
/*
{
deeper: {
and: {
deeper: 'path/to/file.png'
}
}
}
*/
Vladimir Kalmykov vladimirmorulus@gmail.com
Under MIT license, 2018
FAQs
Webpack complex loader
The npm package complex-loader receives a total of 7 weekly downloads. As such, complex-loader popularity was classified as not popular.
We found that complex-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.