
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
drupal-libraries-webpack-plugin
Advanced tools
Generates a Drupal asset library file for a webpack build.
This plugin generates a Drupal asset library file based on a webpack build.
It requires webpack 5 to work. For webpack 4 use the 1.x
version of this plugin.
npm install --save-dev drupal-libraries-webpack-plugin
webpack.config.js
const DrupalLibrariesPlugin = require('drupal-libraries-webpack-plugin');
module.exports = {
plugins: [
new DrupalLibrariesPlugin()
],
};
By default, when you compile webpack, the drupal library file will be generated to 'webpack.libraries.yml'.
The plugin will automatically figure out what libraries need to depend on other libraries based on the final webpack chunks.
You can explicitly add a Drupal library dependency to module by using a special require
statement:
require('@drupal(core/jquery)')
Drupal libraries must be added as external dependencies in your webpack configuration:
externals: {
'@drupal(drupal/core)': 'Drupal'
}
path
Type: String|Function
Default: 'webpack.libraries.yml'
Specifies a custom public path for the target webpack file relative to the process working directory.
webpack.config.js
module.exports = {
plugins: [
new DrupalLibrariesPlugin({
path: 'my-theme-name.libraries.yml',
})
],
};
Split a library into multiple library files.
module.exports = {
plugins: [
new DrupalLibrariesPlugin({
path: (library, metadata) => {
const lib1 = new DrupalLibraryFile('a.libraries.yml'),
lib2 = new DrupalLibraryFile('webpack.libraries.yml')
Object.keys(library).forEach(name => {
if (name == 'a') {
lib1.add(name, library, metdata)
}
else {
lib2.add(name, library, metadata)
}
})
return [lib1, lib2]
}
})
],
};
nameGenerator
Type: Function
Default: nameGenerator
Generates a library name for a chunk.
webpack.config.js
module.exports = {
plugins: [
new DrupalLibrariesPlugin({
nameGenerator: chunk => chunk.hash
})
],
};
requirePattern
Type: RegExp
Default: /^@drupal\(([^\)]+)\)$/
The pattern to use for detecting drupal library dependencies.
module.exports = {
plugins: [
new DrupalLibrariesPlugin({
// Only pick up require('jquery') or require('Drupal') statements.
requirePattern: /^(jquery|Drupal)$/
})
],
};
prepareFile
Type: Function
Default: DrupalLibrariesPlugin.defaults.prepareFile
Prepares a library file that is about to be written.
webpack.config.js
module.exports = {
plugins: [
new DrupalLibrariesPlugin({
prepareFile: (file, compiler, compilation) => {
// Add an extra entry to the file when outputting
file.content['external'] = {
remote: 'https://external-library.js',
}
return DrupalLibrariesPlugin.defaults.prepareFile(file, compiler, compilation)
},
})
],
};
libraryEntryGenerator
Type: DrupalLibraryEntryGenerator
Default: DrupalLibraryEntryGenerator
Generates a flat Drupal library entry as a javascript object from a DrupalLibraryMetadata
object.
webpack.config.js
class StaticVersionLibraryGenerator extends DrupalLibraryEntryGenerator {
constructor(version) {
this.version = version
}
async versionGenerator(metadata) {
return this.version
}
}
module.exports = {
plugins: [
new DrupalLibrariesPlugin({
libraryEntryGenerator: new StaticVersionLibraryGenerator('2.0'),
})
],
};
FAQs
Generates a Drupal asset library file for a webpack build.
The npm package drupal-libraries-webpack-plugin receives a total of 326 weekly downloads. As such, drupal-libraries-webpack-plugin popularity was classified as not popular.
We found that drupal-libraries-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.