Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-12-16 17:09:44 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
2a4ff6fb6af18fb0b7ae98ddb6434a19899c73d1
2a4ff6fb
1 parent
f4b342a5
Implemented custom asset versioning to make creating releases easier
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
6 deletions
app/helpers.php
composer.json
gulpfile.js
package.json
resources/views/base.blade.php
app/helpers.php
0 → 100644
View file @
2a4ff6f
<?php
if
(
!
function_exists
(
'versioned_asset'
))
{
/**
* Get the path to a versioned file.
*
* @param string $file
* @return string
*
* @throws \InvalidArgumentException
*/
function
versioned_asset
(
$file
)
{
static
$manifest
=
null
;
if
(
is_null
(
$manifest
))
{
$manifest
=
json_decode
(
file_get_contents
(
public_path
(
'build/manifest.json'
)),
true
);
}
if
(
isset
(
$manifest
[
$file
]))
{
return
'/'
.
$manifest
[
$file
];
}
if
(
file_exists
(
public_path
(
$file
)))
{
return
'/'
.
$file
;
}
throw
new
InvalidArgumentException
(
"File
{
$file
}
not defined in asset manifest."
);
}
}
\ No newline at end of file
composer.json
View file @
2a4ff6f
...
...
@@ -25,7 +25,10 @@
],
"psr-4"
:
{
"BookStack
\\
"
:
"app/"
}
},
"files"
:
[
"app/helpers.php"
]
},
"autoload-dev"
:
{
"classmap"
:
[
...
...
gulpfile.js
View file @
2a4ff6f
var
elixir
=
require
(
'laravel-elixir'
);
// Custom extensions
var
gulp
=
require
(
'gulp'
);
var
Task
=
elixir
.
Task
;
var
fs
=
require
(
'fs'
);
elixir
.
extend
(
'queryVersion'
,
function
(
inputFiles
)
{
new
Task
(
'queryVersion'
,
function
()
{
var
manifestObject
=
{};
var
uidString
=
Date
.
now
().
toString
(
16
).
slice
(
4
);
for
(
var
i
=
0
;
i
<
inputFiles
.
length
;
i
++
)
{
var
file
=
inputFiles
[
i
];
manifestObject
[
file
]
=
file
+
'?version='
+
uidString
;
}
var
fileContents
=
JSON
.
stringify
(
manifestObject
,
null
,
1
);
fs
.
writeFileSync
(
'public/build/manifest.json'
,
fileContents
);
}).
watch
([
'./public/css/*.css'
,
'./public/js/*.js'
]);
});
elixir
(
function
(
mix
)
{
mix
.
sass
(
'styles.scss'
)
.
sass
(
'print-styles.scss'
)
.
browserify
([
'jquery-extensions.js'
,
'global.js'
],
'public/js/common.js'
)
.
v
ersion
([
'css/styles.css'
,
'css/print-styles.css'
,
'js/common.js'
]);
.
queryV
ersion
([
'css/styles.css'
,
'css/print-styles.css'
,
'js/common.js'
]);
});
...
...
package.json
View file @
2a4ff6f
{
"private"
:
true
,
"devDependencies"
:
{
"gulp"
:
"^3.
8.8
"
,
"gulp"
:
"^3.
9.0
"
,
"insert-css"
:
"^0.2.0"
},
"dependencies"
:
{
...
...
resources/views/base.blade.php
View file @
2a4ff6f
...
...
@@ -9,8 +9,8 @@
<meta
charset=
"utf-8"
>
<!-- Styles and Fonts -->
<link
rel=
"stylesheet"
href=
"{{
elixir
('css/styles.css') }}"
>
<link
rel=
"stylesheet"
media=
"print"
href=
"{{
elixir
('css/print-styles.css') }}"
>
<link
rel=
"stylesheet"
href=
"{{
versioned_asset
('css/styles.css') }}"
>
<link
rel=
"stylesheet"
media=
"print"
href=
"{{
versioned_asset
('css/print-styles.css') }}"
>
<link
href=
'//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300'
rel=
'stylesheet'
type=
'text/css'
>
<link
rel=
"stylesheet"
href=
"/libs/material-design-iconic-font/css/material-design-iconic-font.min.css"
>
...
...
@@ -79,6 +79,6 @@
</section>
@yield('bottom')
<script
src=
"{{
elixir
('js/common.js') }}"
></script>
<script
src=
"{{
versioned_asset
('js/common.js') }}"
></script>
</body>
</html>
...
...
Please
register
or
sign in
to post a comment