2017 © Pedro Peláez
 

library laravel-js-config

Publish Laravel configuration to JS

image

kkszymanowski/laravel-js-config

Publish Laravel configuration to JS

  • Wednesday, November 8, 2017
  • by KKSzymanowski
  • Repository
  • 1 Watchers
  • 0 Stars
  • 54 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 8 % Grown

The README.md

Laravel-JS-Config

Easily publish your Laravel configuration to JavaScript., (*1)

Requirements

  • PHP 7.*
  • Laravel >= 5.2

Installation

composer require kkszymanowski/laravel-js-config

On Laravel < 5.5 add LaravelJsConfig\LaravelJsConfigServiceProvider::class to app/config.php., (*2)

On Laravel >= 5.5 the service provider should be automatically discovered., (*3)

Publish assets

php artisan vendor:publish

Configure

In config/js-config.php there are following configuration options., (*4)

Output

Path of the output file generated from the command. By default resources/assets/js/config.js, (*5)

Pretty

If true, the command will format the JSON configuration using JSON_PRETTY_PRINT., (*6)

Keys

List of configuration keys to be published. Can be either a specific key(like app.env) or a group of keys(like auth.defaults), (*7)

Make sure you don't publish your application key or any passwords., (*8)

Run

php artisan config:js

Integration with Laravel Mix

To publish the configuration every time the Mix build starts follow these steps: 1. Install webpack-shell-plugin: ``` # NPM npm install webpack-shell-plugin --save-dev, (*9)

# Yarn
yarn add webpack-shell-plugin 
```

2. In your 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'], }), ], });, (*10)

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., (*11)

The Versions

08/11 2017

dev-master

9999999-dev

Publish Laravel configuration to JS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kuba Szymanowski

laravel config javascript

08/11 2017

1.0.5

1.0.5.0

Publish Laravel configuration to JS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kuba Szymanowski

laravel config javascript

20/09 2017

1.0.4

1.0.4.0

Publish Laravel configuration to JS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kuba Szymanowski

laravel config javascript

05/09 2017

1.0.3

1.0.3.0

Publish Laravel configuration to JS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kuba Szymanowski

laravel config javascript

05/09 2017

1.0.2

1.0.2.0

Publish Laravel configuration to JS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kuba Szymanowski

laravel config javascript

05/09 2017

1.0.1

1.0.1.0

Publish Laravel configuration to JS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kuba Szymanowski

laravel config javascript