Gathering detailed insights and metrics for twig-asset-webpack-plugin
Gathering detailed insights and metrics for twig-asset-webpack-plugin
Gathering detailed insights and metrics for twig-asset-webpack-plugin
Gathering detailed insights and metrics for twig-asset-webpack-plugin
npm install twig-asset-webpack-plugin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
69
Supply Chain
98.8
Quality
75.4
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
4,165
Last Day
3
Last Week
4
Last Month
18
Last Year
473
1 Stars
64 Commits
1 Forks
2 Watching
6 Branches
1 Contributors
Latest Version
2.0.0
Package Id
twig-asset-webpack-plugin@2.0.0
Unpacked Size
20.33 kB
Size
6.08 kB
File Count
9
NPM Version
7.24.0
Node Version
16.10.0
Cumulative downloads
Total Downloads
Last day
0%
3
Compared to previous day
Last week
100%
4
Compared to previous week
Last month
12.5%
18
Compared to previous month
Last year
-17.9%
473
Compared to previous year
1
21
Webpack 5 plugin to add assets referenced in Twig files to the compilation. This puts them in the generated manifest, so they are available when Twig looks for them.
For example, if it comes across <img src="{{ asset('images/test.png') }}" />
in a Twig file (assuming the
configuration below), the plugin would look for <project-dir>/assets/images/test.png
. If the file is found, it is
added to the Webpack compilation process, copied to the output, and added to the manifest generated by
WebpackManifestPlugin.
1npm install --save-dev twig-asset-webpack-plugin
or
1yarn add --dev twig-asset-webpack-plugin
In your webpack.config.js
1const path = require('path'); 2const { TwigAssetWebpackPlugin } = require('twig-asset-webpack-plugin'); 3 4module.exports = { 5 // ... 6 plugins: [ 7 new TwigAssetWebpackPlugin({ 8 assetPath: path.resolve(__dirname, './assets'), 9 templatePath: path.resolve(__dirname, './templates'), 10 }), 11 ] 12};
When webpack compiles it will now scan templatePath
for Twig files with asset references. It will then add each
reference to the Webpack compilation process.
In your webpack.config.js
1const path = require('path'); 2const { TwigAssetWebpackPlugin } = require('twig-asset-webpack-plugin'); 3 4Encore 5 // ... 6 // We need to remove the default build prefix from the manifest or 7 // when twig attempts to load the asset it will not find it. 8 .setManifestKeyPrefix('') 9 // ... 10 .addPlugin( 11 new TwigAssetWebpackPlugin({ 12 assetPath: path.resolve(__dirname, './assets'), 13 templatePath: path.resolve(__dirname, './templates'), 14 }) 15 ) 16;
options.assetPath
(Required)Type: String
Default: undefined
The absolute path to load asset files from. The asset reference in the Twig template should be relative to this path.
options.templatePath
(Required*)Type: String
Default: undefined
The absolute path to search for Twig files in. This should be undefined if assetLocator
is set manually.
options.assetLocator
Type: AssetLocatorInterface
Default: undefined
The locator used to find Twig files. If templatePath
is specified and this is not, an AssetLocator
instance will
be created with the default options.
options.filename
Type: String
Default: undefined
The output filename format. It must end in .[ext]
if specified. If not specified the webpack output.filename
option will be used (the extension will automatically be replaced with .[ext]
).
options.fileMatch
Type: RegExp
Default: /\.html\.twig$/
The template file names matching this will be searched for asset references.
options.assetMatch
Type: RegExp
Default: /asset\((['"])((?!\1).+)\1\)/g
The regex to use searching for assets in Twig files.
options.assetMatchIndex
Type: Number
Default: 2
The index to pull the file name from the assetMatch
match.
options.excludedMatches
Type: RegExp[]
Default: [/node_modules/]
The template file or directory names matching this will be excluded from processing.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
18 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More