Skip to content

Commit f2ff35f

Browse files
committed
(feat) scripts: demo generation shell scripts added
1 parent 9ecf44c commit f2ff35f

File tree

4 files changed

+153
-1
lines changed

4 files changed

+153
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ npm-debug.log
1515
yarn-error.log
1616
/.idea
1717
/.vscode
18-
18+
free-package.zip
19+
demo
20+
demo.zip
1921
.DS_Store
2022
node_modules
2123
/dist

shell-scripts/gen-demo.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# env make production
4+
sed -i "s/APP_ENV=local/APP_ENV=production/g" ./.env
5+
6+
cp -r public public.bak
7+
8+
cp -r ./shell-scripts/index.php ./public/index.php
9+
10+
mv webpack.mix.js webpack.mix.js.bak
11+
12+
cp -r ./shell-scripts/webpack.mix.js .
13+
14+
# set your base path inside the
15+
sed -i "s/base: process.env.BASE_URL/base: '\/demo\/materio-vuetify-vuejs-laravel-admin-template-free\/demo\/'/g" ./resources/js/src/router/index.js
16+
17+
yarn prod
18+
19+
sed -i "s/base: '\/demo\/materio-vuetify-vuejs-laravel-admin-template-free\/demo\/'/base: process.env.BASE_URL/g" ./resources/js/src/router/index.js
20+
21+
cp -r ./public ./demo
22+
23+
rm -rf public
24+
rm -rf webpack.mix.js
25+
26+
# restore publi and webpack file
27+
mv public.bak public
28+
mv webpack.mix.js.bak webpack.mix.js
29+
30+
# revert to local
31+
sed -i "s/APP_ENV=production/APP_ENV=local/g" ./.env
32+
33+
zip -r demo.zip demo
34+
35+
rm -rf demo

shell-scripts/index.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
use Illuminate\Contracts\Http\Kernel;
4+
use Illuminate\Http\Request;
5+
6+
define('LARAVEL_START', microtime(true));
7+
8+
/*
9+
|--------------------------------------------------------------------------
10+
| Check If The Application Is Under Maintenance
11+
|--------------------------------------------------------------------------
12+
|
13+
| If the application is in maintenance / demo mode via the "down" command
14+
| we will load this file so that any pre-rendered content can be shown
15+
| instead of starting the framework, which could cause an exception.
16+
|
17+
*/
18+
19+
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
20+
require __DIR__.'/../storage/framework/maintenance.php';
21+
}
22+
23+
/*
24+
|--------------------------------------------------------------------------
25+
| Register The Auto Loader
26+
|--------------------------------------------------------------------------
27+
|
28+
| Composer provides a convenient, automatically generated class loader for
29+
| this application. We just need to utilize it! We'll simply require it
30+
| into the script here so we don't need to manually load our classes.
31+
|
32+
*/
33+
34+
require __DIR__.'/../vendor/autoload.php';
35+
36+
/*
37+
|--------------------------------------------------------------------------
38+
| Run The Application
39+
|--------------------------------------------------------------------------
40+
|
41+
| Once we have the application, we can handle the incoming request using
42+
| the application's HTTP kernel. Then, we will send the response back
43+
| to this client's browser, allowing them to enjoy our application.
44+
|
45+
*/
46+
47+
$app = require_once __DIR__.'/../bootstrap/app.php';
48+
49+
$app->bind('path.public', function() {
50+
return base_path('demo');
51+
});
52+
53+
$kernel = $app->make(Kernel::class);
54+
55+
$response = tap($kernel->handle(
56+
$request = Request::capture()
57+
))->send();
58+
59+
$kernel->terminate($request, $response);

shell-scripts/webpack.mix.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const mix = require('laravel-mix')
2+
const path = require('path')
3+
require('vuetifyjs-mix-extension')
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Mix Asset Management
8+
|--------------------------------------------------------------------------
9+
|
10+
| Mix provides a clean, fluent API for defining some Webpack build steps
11+
| for your Laravel applications. By default, we are compiling the CSS
12+
| file for the application as well as bundling up all the JS files.
13+
|
14+
*/
15+
const webpack = {
16+
resolve: {
17+
alias: {
18+
'@resources': path.resolve(__dirname, 'resources/'),
19+
'@': path.resolve(__dirname, 'resources/js/src/'),
20+
},
21+
},
22+
}
23+
24+
mix.webpackConfig(webpack)
25+
26+
mix
27+
.js('resources/js/app.js', 'public/js')
28+
.vuetify('vuetify-loader', './resources/sass/styles/variables.scss')
29+
.vue()
30+
.copyDirectory('resources/js/src/assets/images', 'public/images')
31+
32+
// ------------------------------------------------
33+
// If you are deploying on subdomain/subfolder. Uncomment below code before running 'yarn prod' or 'npm run production' command.
34+
// Please Change below 'publicPath' and 'setResourceRoot' options as per your sub-directory path. We have kept our current live demo options which is deployed in sub-folder.
35+
// ------------------------------------------------
36+
37+
if (mix.inProduction()) {
38+
mix.version()
39+
mix.webpackConfig({
40+
output: {
41+
publicPath: '/demo/materio-vuetify-vuejs-laravel-admin-template-free/demo/',
42+
chunkFilename: 'js/chunks/[name].[chunkhash].js',
43+
},
44+
})
45+
mix.setResourceRoot('/demo/materio-vuetify-vuejs-laravel-admin-template-free/demo/')
46+
}
47+
48+
// ------------------------------------------------
49+
// If you are deploying on subdomain/subfolder then comment out below code before running 'yarn prod' or 'npm run production' command.
50+
// ------------------------------------------------
51+
52+
// mix.webpackConfig({
53+
// output: {
54+
// chunkFilename: "js/chunks/[name].[chunkhash].js",
55+
// },
56+
// });

0 commit comments

Comments
 (0)