Download the PHP package la-haute-societe/craft-webpack-assets without Composer
On this page you can find all versions of the php package la-haute-societe/craft-webpack-assets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download la-haute-societe/craft-webpack-assets
More information about la-haute-societe/craft-webpack-assets
Files in la-haute-societe/craft-webpack-assets
Package craft-webpack-assets
Short Description Webpack assets for Craft CMS
License MIT
Informations about the package craft-webpack-assets
Webpack assets - Craft plugin
A simple plugin allowing to handle Webpack generated CSS and Javascript assets within Craft CMS templates.
Requirements
This plugin requires Craft CMS 3.0.0-RC1 or later. It is intended to work with Webpack 2 or 3.
Installation
- Install with composer from your project directory:
Webpack setup
-
To generate the intended JSON files, add the following NPM packages:
-
Somewhere in your assets source folder, create a
assets-files.json.tpl
file with the following content : - In the Webpack config add the following plugins :
Adjust the
template
value to the path of the previously createdassets-files.json.tpl
file.
- Finally, run your Webpack process, as usual.
Configuration
In the config
folder at the root of your Craft project, create a webpackassets.php
file with the following content
and adjust the path to the JSON generated by Webpack.
Usage
In your Twig templates, you can include your Webpack generated assets as follow:
You can detect if the public path provided by webpack is an absolute URL with the method isPublicPathAbsoluteUrl
(this is the case when assets are served by Webpack).
If needed, you can override the webpack public path at runtime when this path is not absolute :
Brought to you by La Haute Société