These files allow you to compile JavaScript in your plugins, while using the Production Template.
- Copy the files
package.json
andwebpack.config.prod.js
to the root of your project - Run
yarn install
- Modify
package.json
to add a newbuild
andwatch
with the path to your plugin specified in the constantPLUGIN_FOLDER
Run yarn build
with the PLUGIN_FOLDER
set to compile all sources for production:
PLUGIN_FOLDER=custom/plugins/SwagExample yarn build
Run yarn watch
with the PLUGIN_FOLDER
set to compile all sources for development and keep watching
all files:
PLUGIN_FOLDER=custom/plugins/SwagExample yarn watch
The Webpack build includes a post-script to run bin/console theme:compile
.
Unfortunately, this usually takes about 3.5 seconds before finishing, largely due to
CSS. The PR 1863 adds an option
skip-css
to the command to allow quicker completion. This could be used again with
this Webpack build as so:
THEME_COMPILE_OPTIONS='-k --skip-css' PLUGIN_FOLDER=custom/plugins/SwagExample yarn build