chialab/rna-cakephp
最新稳定版本:v0.3.0
Composer 安装命令:
composer require chialab/rna-cakephp
包简介
A CakePHP plugin to seamlessly integrate with @chialab/rna build artifacts.
README 文档
README
A CakePHP plugin to seamlessly integrate with @chialab/rna build artifacts.
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require chialab/rna-cakephp
You must load the plugin into your CakePHP application by loading it in your application class bootstrap method:
class Application extends \Cake\Http\BaseApplication { public function bootstrap(): void { parent::bootstrap(); // ... $this->addPlugin('Chialab/Rna'); } }
Usage
RNA Helper
Load the helper in your view class:
class View extends \Cake\View\View { public function initialize(): void { parent::initialize(); // ... $this->loadHelper('Chialab/Rna.Rna'); } }
Then use it in your templates:
-
To inject the code generated by the dev server (only when
debugis on):{{ Rna.devServer()|raw }} {{ Rna.devServer('YourPlugin')|raw }} -
To load resources:
{{ Rna.script('index')|raw }} {{ Rna.css('YourPlugin.main')|raw }} {{ Rna.script('YourPlugin.main', { type: 'module' })|raw }}
Migrate from Symfony Encore
Follow this instructions to migrate from a Webpack Encore based configuration:
- Create a
rna.config.jsfile in the root of yuor project. - Define entrypoints
/** * @param {import('@chialab/rna-config-loader').Config} config * @param {import('@chialab/rna-config-loader').Mode} mode */ export default function(config, mode) { return { ...config, entrypoints: [ // Encore.addEntry('section-filters', `./resources/js/section-filters.js`) { input: [ './resources/js/section-filters.js', ], output: '/webroot/build', }, // Encore.addEntry('app', './resources/js/app.js').addStyleEntry('app-style'', './resources/css/app.css') // Encore.script('app') -> Rna.script('app') // Encore.css('app-style') -> Rna.css('app') { input: [ './resources/js/app.js', './resources/js/app.css', ], output: '/webroot/build', }, ], }; }
- Extend the RNA configuration
export default function(config, mode) { return { ...config, entrypoints: [...], // Encore.cleanupOutputBeforeBuild() clean: true, // Encore.enableSourceMaps(!Encore.isProduction()) minify: mode === 'build', sourcemap: mode !== 'build', // Encore.enableVersioning(Encore.isProduction()) entryNames: mode === 'build' ? '[name]-[hash]' : '[name]', chunkNames: mode === 'build' ? '[name]-[hash]' : '[name]', assetNames: mode === 'build' ? 'assets/[name]-[hash]' : '[name]', // Encore.setPublicPath('/webroot/build') manifestPath: 'webroot/build/manifest.json', entrypointsPath: 'webroot/build/entrypoints.json', }; }
- Remove
@symfony/webpack-encore,webpackand webpack loaders `
统计信息
- 总下载量: 24.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-06