Package Data | |
---|---|
Maintainer Username: | KKSzymanowski |
Maintainer Contact: | kuba.szymanowski@inf24.pl (Kuba Szymanowski) |
Package Create Date: | 2017-09-05 |
Package Last Update: | 2022-10-24 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-22 03:17:27 |
Package Statistics | |
---|---|
Total Downloads: | 5,480 |
Monthly Downloads: | 11 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Easily publish your Laravel configuration to JavaScript.
composer require kkszymanowski/laravel-js-config
On Laravel < 5.5 add LaravelJsConfig\LaravelJsConfigServiceProvider::class
to app/config.php
.
On Laravel >= 5.5 the service provider should be automatically discovered.
php artisan vendor:publish
In config/js-config.php
there are following configuration options.
Path of the output file generated from the command. By default resources/assets/js/config.js
If true, the command will format the JSON configuration using JSON_PRETTY_PRINT
.
List of configuration keys to be published.
Can be either a specific key(like app.env
) or a group of keys(like auth.defaults
)
Make sure you don't publish your application key or any passwords.
php artisan config:js
To publish the configuration every time the Mix build starts follow these steps:
webpack-shell-plugin
:
# NPM
npm install webpack-shell-plugin --save-dev
# Yarn
yarn add webpack-shell-plugin
webpack.mix.js
file require the plugin
const WebpackShellPlugin = require('webpack-shell-plugin');
and register it to run before each build
mix.webpackConfig({
plugins: [
new WebpackShellPlugin({
onBuildStart: ['php artisan config:js'],
}),
],
});
If you're using the watch
option in Laravel Mix and you want to refresh the published configuration you can either restart the build or run php artisan config:js
in another terminal.