Add and update asset version numbers in your *.libraries.yml file automatically using git status and the file paths from webpack.mix.js.
- Configure the
dalv
command that was added in the scripts section of package.json. Configuration details below. - Add the
dalv
command to the end of theproduction
command in the scripts section of package.json - The script will run automatically on
npm run production
.
On npm install, following script command will be automatically prepended to the scripts section of package.json.
"dalv": "drupal-asset-library-versions --compiledFiles=main.js,main.css --librariesYmlDir=../"
This command can be used on its own npm run dalv
, however, it should to be added to the end of the production
command for a more succinct workflow, and also so the script can work with specified compiled files.
E.g.
"production": "npx mix --production && npm run dalv"
The compiledFiles
config option is provided to specify compiled files that map to a library in *.libraries.yml. main.js,main.css
are the default values. This is a comma separated list.
The librariesYmlDir
config option is provided to specify the location of *.libraries.yml relative to the current directory (i.e. where package.json is located). The default value is ../
.