Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
raw-edit-loader
Advanced tools
A loader for webpack, support modify source string. Through the configuration of a series of properties, to modify the matching string
A loader for webpack, support modify source string. Through the configuration of a series of properties, to modify the matching string.
npm i -D raw-edit-loader
General configuration:
// src/index.js
console.log('Hello world!')
// webpack.config.js
{
test: /\.js$/,
use: ['babel-loader', {
loader: 'raw-edit-loader',
options: {
// pathList: [path.resolve(__dirname, './src/index.js')],
pathReg: /src\/index.js/,
replaceReg: /Hello/,
replacement: 'Hi, ',
done: function(source) {
return source
},
}
}],
}
Before passing in the next loader, the source will be modified to:
// source string
console.log('Hi, wold!')
or group matching:
// webpack.config.js
{
test: /\.js$/,
use: ['babel-loader', {
loader: 'raw-edit-loader',
options: {
group: [
{
pathReg: /src\/index.js/,
replaceReg: /Hello/,
replacement: 'Hi, ',
done: function(source) {
return source
},
}
]
}
}],
}
Matching file absolute path list. If pathReg configured, the property will be invalid.
{
pathList: ['/path/to/index.js', '/path/to/b.js']
}
Matching file path regular expression. If pathList configured, the property will be invalid.
{
pathReg: /src\/index.js/,
}
Match the source string regular expression and the hit fragment will be replaced.
{
replaceReg: /Hello/,
}
Match the source string regular expression and the hit fragment will be replaced. string.replace(replaceReg, replacement)
{
replacement: 'Hi, ',
}
If the matching group is configured, the single mode property will be invalid
{
group: [
{
pathReg: /src\/index.js/,
replaceReg: /Hello/,
replacement: 'Hi, ',
done: function(source) {
return source
},
},
{
pathReg: /src\/a.js/,
replaceReg: /May/,
replacement: 'Can',
done: function(source) {
return source
},
}
]
}
After the source operation is completed, the done method is called. Need return source.
{
done: function(source) {
return `${source};console.log('hello world')`
},
}
FAQs
A loader for webpack, support modify source string. Through the configuration of a series of properties, to modify the matching string
The npm package raw-edit-loader receives a total of 1 weekly downloads. As such, raw-edit-loader popularity was classified as not popular.
We found that raw-edit-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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.