Skip to content

Commit f8364ab

Browse files
committed
feat(global): first commit
0 parents  commit f8364ab

30 files changed

+17250
-0
lines changed

.gitignore

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (https://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# TypeScript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
.env.test
64+
65+
# parcel-bundler cache (https://parceljs.org/)
66+
.cache
67+
68+
# next.js build output
69+
.next
70+
71+
# nuxt.js build output
72+
.nuxt
73+
74+
# vuepress build output
75+
.vuepress/dist
76+
77+
# Serverless directories
78+
.serverless/
79+
80+
# FuseBox cache
81+
.fusebox/
82+
83+
# DynamoDB Local files
84+
.dynamodb/
85+
86+
# source maps
87+
*.js.map
88+
89+
# build output
90+
public
91+
storage
92+
93+
# IDEs
94+
.vscode
95+
.idea

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Michael Marcenich ([@mentAl-maZe](https://github.com/mentAl-maZe))
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README-template.md

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Nuxt Laravel
2+
3+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
4+
5+
## Jest coverage
6+
7+
| Statements | Branches | Functions | Lines |
8+
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
9+
| ![Statements](#statements#) | ![Branches](#branches#) | ![Functions](#functions#) | ![Lines](#lines#) |
10+
11+
This package allows to develop a nuxt SPA as frontend for a laravel backend.
12+
The implementation is based on [laravel-nuxt-js](https://github.com/skyrpex/laravel-nuxt-js) by [skyrpex](https://github.com/skyrpex).
13+
> **Hint:** Use his composer exension [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt) for dotenv support
14+
15+
## Installation
16+
17+
Install the package and its peer dependencies.
18+
19+
```bash
20+
npm install --save nuxt @nuxtjs/axios @nuxtjs/proxy nuxt-laravel
21+
```
22+
23+
## Usage
24+
25+
The package provides a binary which extends the `@nuxt/cli`, therefore you can use it directly with the nuxt cli command.
26+
27+
In you package json:
28+
29+
```json
30+
{
31+
"scripts": {
32+
"dev": "nuxt laravel",
33+
"start": "npm run dev",
34+
"build": "nuxt laravel build"
35+
}
36+
}
37+
```
38+
39+
## Commands
40+
41+
### Development
42+
43+
```bash
44+
npx nuxt laravel
45+
```
46+
47+
or
48+
49+
```bash
50+
npx nuxt laravel dev
51+
```
52+
53+
Starts both Nuxt and Laravel artisan servers in development mode (hot-code reloading, error reporting, etc).
54+
55+
#### Additional `dev` options
56+
57+
In addition to the default `nuxt dev` command, the following options are provided:
58+
59+
| option | description | default |
60+
| ---------------- | ------------------------------- | --------------------- |
61+
| `--render-path` | URL path used to render the SPA | `'/__nuxt_laravel__'` |
62+
| `--laravel-path` | Path to laravel directory | `process.cwd()` |
63+
64+
If laravel path is provided a relative path it is resolved relative to `process.cwd()`.
65+
66+
#### Laravel integration in development
67+
68+
Render path is provided as environment variable `NUXT_URL` to `php artisan serve`.
69+
Use it in your `routes/web.php` to redirect all web traffic to or just use [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt).
70+
71+
**Example `routes/web.php`:**
72+
73+
without `nuxt-laravel`
74+
75+
```php
76+
// ...
77+
// Add this route the last, so it doesn't interfere with your other routes.
78+
Route::get(
79+
'{uri}',
80+
function($request, $uri) {
81+
// If the request expects JSON, it means that
82+
// someone sent a request to an invalid route.
83+
if ($request->expectsJson()) {
84+
abort(404);
85+
}
86+
87+
// Fetch and display the page from the render path on nuxt dev server
88+
return file_get_contents(env('NUXT_URL'));
89+
}
90+
)->where('uri', '.*');
91+
```
92+
93+
with `nuxt-laravel`
94+
95+
```php
96+
// ...
97+
// Add this route the last, so it doesn't interfere with your other routes.
98+
Route::get(
99+
'{uri}',
100+
'\\'.Pallares\LaravelNuxt\Controllers\NuxtController::class
101+
)->where('uri', '.*');
102+
```
103+
104+
### Production
105+
106+
```bash
107+
laravel-nuxt build
108+
```
109+
110+
Compiles the application for production deployment.
111+
112+
#### Additional `build` options
113+
114+
In addition to the default `nuxt build` command, the following options are provided:
115+
116+
| option | description | default |
117+
| --------------- | ------------------------------------------- | -------------------------- |
118+
| `--no-delete` | Do not delete build files after generation | `false` |
119+
| `--file-path` | Location for the SPA index file | `'storage/app/index.html'` |
120+
| `--public-path` | The folder where laravel serves assets from | `'public'` |
121+
122+
If file path or public path are relative they are resolved relative to `rootDir` from `nuxt.config`.
123+
124+
> **Attention:** If either path does not exists it is created recursively
125+
126+
#### Laravel integration in production
127+
128+
If not provided, the file path is first checked against `process.env.NUXT_URL` so you can also set it using the environment variable.
129+
The command loads `require('dotenv').config()` so you can provide `NUXT_URL` in a `.env` file.
130+
131+
Or just use [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt).

README.md

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Nuxt Laravel
2+
3+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
4+
5+
## Jest coverage
6+
7+
| Statements | Branches | Functions | Lines |
8+
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
9+
| ![Statements](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Functions](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) |
10+
11+
This package allows to develop a nuxt SPA as frontend for a laravel backend.
12+
The implementation is based on [laravel-nuxt-js](https://github.com/skyrpex/laravel-nuxt-js) by [skyrpex](https://github.com/skyrpex).
13+
> **Hint:** Use his composer exension [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt) for dotenv support
14+
15+
## Installation
16+
17+
Install the package and its peer dependencies.
18+
19+
```bash
20+
npm install --save nuxt @nuxtjs/axios @nuxtjs/proxy nuxt-laravel
21+
```
22+
23+
## Usage
24+
25+
The package provides a binary which extends the `@nuxt/cli`, therefore you can use it directly with the nuxt cli command.
26+
27+
In you package json:
28+
29+
```json
30+
{
31+
"scripts": {
32+
"dev": "nuxt laravel",
33+
"start": "npm run dev",
34+
"build": "nuxt laravel build"
35+
}
36+
}
37+
```
38+
39+
## Commands
40+
41+
### Development
42+
43+
```bash
44+
npx nuxt laravel
45+
```
46+
47+
or
48+
49+
```bash
50+
npx nuxt laravel dev
51+
```
52+
53+
Starts both Nuxt and Laravel artisan servers in development mode (hot-code reloading, error reporting, etc).
54+
55+
#### Additional `dev` options
56+
57+
In addition to the default `nuxt dev` command, the following options are provided:
58+
59+
| option | description | default |
60+
| ---------------- | ------------------------------- | --------------------- |
61+
| `--render-path` | URL path used to render the SPA | `'/__nuxt_laravel__'` |
62+
| `--laravel-path` | Path to laravel directory | `process.cwd()` |
63+
64+
If laravel path is provided a relative path it is resolved relative to `process.cwd()`.
65+
66+
#### Laravel integration in development
67+
68+
Render path is provided as environment variable `NUXT_URL` to `php artisan serve`.
69+
Use it in your `routes/web.php` to redirect all web traffic to or just use [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt).
70+
71+
**Example `routes/web.php`:**
72+
73+
without `nuxt-laravel`
74+
75+
```php
76+
// ...
77+
// Add this route the last, so it doesn't interfere with your other routes.
78+
Route::get(
79+
'{uri}',
80+
function($request, $uri) {
81+
// If the request expects JSON, it means that
82+
// someone sent a request to an invalid route.
83+
if ($request->expectsJson()) {
84+
abort(404);
85+
}
86+
87+
// Fetch and display the page from the render path on nuxt dev server
88+
return file_get_contents(env('NUXT_URL'));
89+
}
90+
)->where('uri', '.*');
91+
```
92+
93+
with `nuxt-laravel`
94+
95+
```php
96+
// ...
97+
// Add this route the last, so it doesn't interfere with your other routes.
98+
Route::get(
99+
'{uri}',
100+
'\\'.Pallares\LaravelNuxt\Controllers\NuxtController::class
101+
)->where('uri', '.*');
102+
```
103+
104+
### Production
105+
106+
```bash
107+
laravel-nuxt build
108+
```
109+
110+
Compiles the application for production deployment.
111+
112+
#### Additional `build` options
113+
114+
In addition to the default `nuxt build` command, the following options are provided:
115+
116+
| option | description | default |
117+
| --------------- | ------------------------------------------- | -------------------------- |
118+
| `--no-delete` | Do not delete build files after generation | `false` |
119+
| `--file-path` | Location for the SPA index file | `'storage/app/index.html'` |
120+
| `--public-path` | The folder where laravel serves assets from | `'public'` |
121+
122+
If file path or public path are relative they are resolved relative to `rootDir` from `nuxt.config`.
123+
124+
> **Attention:** If either path does not exists it is created recursively
125+
126+
#### Laravel integration in production
127+
128+
If not provided, the file path is first checked against `process.env.NUXT_URL` so you can also set it using the environment variable.
129+
The command loads `require('dotenv').config()` so you can provide `NUXT_URL` in a `.env` file.
130+
131+
Or just use [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt).

bin/cli.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
3+
require('../dist/cli.js')
4+
.run()
5+
.catch(error => {
6+
require('consola').fatal(error)
7+
require('exit')(2)
8+
})

0 commit comments

Comments
 (0)