dawen / config-to-js-bundle
提供将定义的配置导出到js文件的命令
1.0.0
2016-02-04 10:03 UTC
Requires
- php: >=5.5.0
- symfony/console: ~2.8|~3.0
- symfony/framework-bundle: ~2.8|~3.0
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-09-14 18:09:48 UTC
README
提供将定义的配置导出到js文件的命令。
安装
步骤 1: Composer
需要在 composer.json 中指定
"dawen/config-to-js-bundle": "~1.0"
修改 composer.json 文件后,运行 composer update dawen/config-to-js-bundle
步骤 2: AppKernel
在你的 app/config/AppKernel.php 文件中,应通过将其添加到数组中激活该组件
$bundles[] = new Dawen\Bundle\ConfigToJsBundle\ConfigToJsBundle();
步骤 3: 配置
config_to_js: type: 'module' output_path: '%kernel.root_dir%/../web/js/app-config.js' config: imageLocation: 'http://this-is-an-example.com/images' appVersion: '1.1.0'
如果参数未定义,则将应用默认值。
步骤 4: 运行命令
转到你的控制台并运行
bin/console config:js:dump
配置参数描述
type
可能值:module 默认值:module 描述:这定义了导出代码优化的目标。
output_path
可能值:有效的文件路径字符串 默认值:null 描述:此参数定义要创建的路径和文件名。如果此值未设置,则导出器将抛出错误。
config
可能值:数组 默认值:空数组 描述:在这里,您可以创建应在您的javascript端可用的配置变量。
支持的类型/渲染器
module: 您的文件可以通过模块模式导入,如下所示:import appConfig from './ccurrent-folder/web/js/app-config.js'