Generate manifest for cache issues
This commit is contained in:
parent
e87c52d30f
commit
d16e7a3dfa
|
|
@ -66,6 +66,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
$this->app->singleton('cipher', 'App\Services\Cipher\\'.config('secure.cipher'));
|
||||
$this->app->singleton('options', \App\Services\Option::class);
|
||||
$this->app->singleton('parsedown', \Parsedown::class);
|
||||
$this->app->singleton('webpack', \App\Services\Webpack::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
24
app/Services/Webpack.php
Normal file
24
app/Services/Webpack.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use File;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Webpack
|
||||
{
|
||||
protected $manifest = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$path = public_path('app/manifest.json');
|
||||
if (File::exists($path)) {
|
||||
$this->manifest = json_decode(File::get($path), true);
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($path)
|
||||
{
|
||||
return url('app').'/'.Arr::get($this->manifest, $path, '');
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ if (! function_exists('webpack_assets')) {
|
|||
// @codeCoverageIgnoreEnd
|
||||
} else {
|
||||
$cdn = option('cdn_address');
|
||||
return $cdn ? "$cdn/app/$relativeUri" : url("app/$relativeUri");
|
||||
return $cdn ? "$cdn/app/$relativeUri" : app('webpack')->$relativeUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@
|
|||
"webpack": "^4.29.6",
|
||||
"webpack-cli": "^3.2.3",
|
||||
"webpack-dev-server": "^3.2.1",
|
||||
"webpack-manifest-plugin": "^2.0.4",
|
||||
"webpackbar": "^3.1.5",
|
||||
"yaml-loader": "^0.5.0"
|
||||
},
|
||||
|
|
|
|||
17
tests/ServicesTest/WebpackTest.php
Normal file
17
tests/ServicesTest/WebpackTest.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use File;
|
||||
use App\Services\Webpack;
|
||||
|
||||
class WebpackTest extends TestCase
|
||||
{
|
||||
public function testManifest()
|
||||
{
|
||||
File::shouldReceive('exists')->andReturn(true);
|
||||
File::shouldReceive('get')->andReturn(json_encode(['a' => 'b']));
|
||||
$key = 'a';
|
||||
$this->assertEquals('http://localhost/app/b', app('webpack')->$key);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ const VueLoaderPlugin = require('vue-loader/lib/plugin')
|
|||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const WebpackBar = require('webpackbar')
|
||||
const ManifestPlugin = require('webpack-manifest-plugin')
|
||||
|
||||
const devMode = !process.argv.includes('-p')
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ const config = {
|
|||
},
|
||||
output: {
|
||||
path: `${__dirname}/public/app`,
|
||||
filename: '[name].js',
|
||||
filename: '[name].[contenthash:7].js',
|
||||
chunkFilename: devMode ? '[id].js' : '[id].[contenthash:7].js',
|
||||
},
|
||||
module: {
|
||||
|
|
@ -102,8 +103,8 @@ const config = {
|
|||
plugins: [
|
||||
new VueLoaderPlugin(),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '[name].css',
|
||||
chunkFilename: '[id].css',
|
||||
filename: '[name].[contenthash:7].css',
|
||||
chunkFilename: '[id].[contenthash:7].css',
|
||||
}),
|
||||
new CopyWebpackPlugin([
|
||||
{
|
||||
|
|
@ -119,6 +120,7 @@ const config = {
|
|||
'resources/assets/src/images/bg.jpg',
|
||||
'resources/assets/src/images/favicon.ico',
|
||||
]),
|
||||
new ManifestPlugin(),
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.vue', '.json'],
|
||||
|
|
|
|||
34
yarn.lock
34
yarn.lock
|
|
@ -4049,6 +4049,15 @@ from2@^2.1.0:
|
|||
inherits "^2.0.1"
|
||||
readable-stream "^2.0.0"
|
||||
|
||||
fs-extra@^7.0.0:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
|
||||
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
|
||||
dependencies:
|
||||
graceful-fs "^4.1.2"
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs-minipass@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
|
||||
|
|
@ -4263,7 +4272,7 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
|
|||
version "4.1.11"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
|
||||
|
||||
graceful-fs@^4.1.15:
|
||||
graceful-fs@^4.1.15, graceful-fs@^4.1.6:
|
||||
version "4.1.15"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
|
||||
|
||||
|
|
@ -5612,6 +5621,13 @@ json5@^1.0.1:
|
|||
dependencies:
|
||||
minimist "^1.2.0"
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
jsonify@~0.0.0:
|
||||
version "0.0.0"
|
||||
resolved "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
|
||||
|
|
@ -5824,7 +5840,7 @@ lodash.uniq@^4.5.0:
|
|||
version "4.5.0"
|
||||
resolved "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||
|
||||
lodash@^4.0.0, lodash@^4.17.11, lodash@~4.17.10:
|
||||
"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.17.11, lodash@~4.17.10:
|
||||
version "4.17.11"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
||||
|
||||
|
|
@ -8973,6 +8989,11 @@ unique-slug@^2.0.0:
|
|||
dependencies:
|
||||
imurmurhash "^0.1.4"
|
||||
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
||||
unpipe@1.0.0, unpipe@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
||||
|
|
@ -9295,6 +9316,15 @@ webpack-log@^2.0.0:
|
|||
ansi-colors "^3.0.0"
|
||||
uuid "^3.3.2"
|
||||
|
||||
webpack-manifest-plugin@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.npmjs.org/webpack-manifest-plugin/-/webpack-manifest-plugin-2.0.4.tgz#e4ca2999b09557716b8ba4475fb79fab5986f0cd"
|
||||
integrity sha512-nejhOHexXDBKQOj/5v5IZSfCeTO3x1Dt1RZEcGfBSul891X/eLIcIVH31gwxPDdsi2Z8LKKFGpM4w9+oTBOSCg==
|
||||
dependencies:
|
||||
fs-extra "^7.0.0"
|
||||
lodash ">=3.5 <5"
|
||||
tapable "^1.0.0"
|
||||
|
||||
webpack-sources@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.2.0.tgz#18181e0d013fce096faf6f8e6d41eeffffdceac2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user