mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
Integrated Webpack for the embedded player.
This commit is contained in:
parent
0c949f0d41
commit
4f6f64a3c0
7 changed files with 32 additions and 90 deletions
|
@ -20,23 +20,6 @@
|
||||||
|
|
||||||
class Assets
|
class Assets
|
||||||
{
|
{
|
||||||
public static function scriptIncludes($area = 'app')
|
|
||||||
{
|
|
||||||
if (!Config::get("app.debug")) {
|
|
||||||
return '<script src="/build/scripts/' . $area . '.js?' . filemtime(public_path("/build/scripts/${area}.js")) . '"></script>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$scripts = self::mergeGlobs(self::getScriptsForArea($area));
|
|
||||||
$retVal = "";
|
|
||||||
|
|
||||||
foreach ($scripts as $script) {
|
|
||||||
$filename = self::replaceExtensionWith($script, ".coffee", ".js");
|
|
||||||
$retVal .= "<script src='/build/$filename?" . filemtime(public_path("/build/${filename}")) . "'></script>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function styleIncludes($area = 'app')
|
public static function styleIncludes($area = 'app')
|
||||||
{
|
{
|
||||||
if (!Config::get("app.debug")) {
|
if (!Config::get("app.debug")) {
|
||||||
|
@ -84,41 +67,6 @@ class Assets
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getScriptsForArea($area)
|
|
||||||
{
|
|
||||||
if ($area == 'app') {
|
|
||||||
return [
|
|
||||||
"scripts/base/jquery-2.0.2.js",
|
|
||||||
"scripts/base/angular.js",
|
|
||||||
"scripts/base/marked.js",
|
|
||||||
"scripts/base/*.{coffee,js}",
|
|
||||||
"scripts/shared/*.{coffee,js}",
|
|
||||||
"scripts/app/*.{coffee,js}",
|
|
||||||
"scripts/app/services/*.{coffee,js}",
|
|
||||||
"scripts/app/filters/*.{coffee,js}",
|
|
||||||
"scripts/app/directives/*.{coffee,js}",
|
|
||||||
"scripts/app/controllers/*.{coffee,js}",
|
|
||||||
"scripts/**/*.{coffee,js}"
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
if ($area == 'embed') {
|
|
||||||
return [
|
|
||||||
"scripts/base/jquery-2.0.2.js",
|
|
||||||
"scripts/base/jquery.cookie.js",
|
|
||||||
"scripts/base/jquery.viewport.js",
|
|
||||||
"scripts/base/underscore.js",
|
|
||||||
"scripts/base/moment.js",
|
|
||||||
"scripts/base/jquery.timeago.js",
|
|
||||||
"scripts/base/soundmanager2-nodebug.js",
|
|
||||||
"scripts/shared/jquery-extensions.js",
|
|
||||||
"scripts/embed/*.coffee"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getStylesForArea($area)
|
private static function getStylesForArea($area)
|
||||||
{
|
{
|
||||||
if ($area == 'app') {
|
if ($area == 'app') {
|
||||||
|
|
33
gulpfile.js
33
gulpfile.js
|
@ -25,7 +25,8 @@ var gulp = require("gulp"),
|
||||||
WebpackDevServer = require("webpack-dev-server"),
|
WebpackDevServer = require("webpack-dev-server"),
|
||||||
webpackDevConfig = require("./webpack.dev.config.js"),
|
webpackDevConfig = require("./webpack.dev.config.js"),
|
||||||
webpackProductionConfig = require("./webpack.production.config.js"),
|
webpackProductionConfig = require("./webpack.production.config.js"),
|
||||||
webpackStream = require('webpack-stream');
|
webpackStream = require('webpack-stream'),
|
||||||
|
_ = require("underscore");
|
||||||
|
|
||||||
var plumberOptions = {
|
var plumberOptions = {
|
||||||
errorHandler: plug.notify.onError("Error: <%= error.message %>")
|
errorHandler: plug.notify.onError("Error: <%= error.message %>")
|
||||||
|
@ -55,7 +56,7 @@ var licenseHeader = [
|
||||||
|
|
||||||
|
|
||||||
gulp.task("webpack-build", function() {
|
gulp.task("webpack-build", function() {
|
||||||
return gulp.src(webpackProductionConfig.entry)
|
return gulp.src(_.values(webpackProductionConfig.entry))
|
||||||
.pipe(webpackStream(webpackProductionConfig))
|
.pipe(webpackStream(webpackProductionConfig))
|
||||||
.pipe(header(licenseHeader))
|
.pipe(header(licenseHeader))
|
||||||
.pipe(gulp.dest('public'));
|
.pipe(gulp.dest('public'));
|
||||||
|
@ -78,33 +79,6 @@ gulp.task("webpack-dev-server", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
gulp.task("scripts-embed", function () {
|
|
||||||
// note that this task should really only ever be invoked for production
|
|
||||||
// since development-mode watches and builds include the embed scripts
|
|
||||||
// already
|
|
||||||
|
|
||||||
var includedScripts = [
|
|
||||||
"resources/assets/scripts/base/jquery-2.0.2.js",
|
|
||||||
"resources/assets/scripts/base/jquery.cookie.js",
|
|
||||||
"resources/assets/scripts/base/jquery.viewport.js",
|
|
||||||
"resources/assets/scripts/base/underscore.js",
|
|
||||||
"resources/assets/scripts/base/moment.js",
|
|
||||||
"resources/assets/scripts/base/jquery.timeago.js",
|
|
||||||
"resources/assets/scripts/base/soundmanager2-nodebug.js",
|
|
||||||
"resources/assets/scripts/shared/jquery-extensions.js",
|
|
||||||
"resources/assets/scripts/embed/*.coffee"
|
|
||||||
];
|
|
||||||
|
|
||||||
return gulp.src(includedScripts, {base: "resources/assets/scripts"})
|
|
||||||
.pipe(plug.plumber(plumberOptions))
|
|
||||||
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
|
||||||
.pipe(plug.order(includedScripts, {base: "."}))
|
|
||||||
.pipe(plug.concat("embed.js"))
|
|
||||||
.pipe(plug.uglify())
|
|
||||||
.pipe(header(licenseHeader))
|
|
||||||
.pipe(gulp.dest("public/build/scripts"));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task("styles-app", function () {
|
gulp.task("styles-app", function () {
|
||||||
var includedStyles = [
|
var includedStyles = [
|
||||||
"resources/assets/styles/base/jquery-ui.css",
|
"resources/assets/styles/base/jquery-ui.css",
|
||||||
|
@ -194,7 +168,6 @@ gulp.task('build', [
|
||||||
'webpack-build',
|
'webpack-build',
|
||||||
'copy:templates',
|
'copy:templates',
|
||||||
'styles-app',
|
'styles-app',
|
||||||
'scripts-embed',
|
|
||||||
'styles-embed'
|
'styles-embed'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,10 @@ require 'script!../base/moment'
|
||||||
require '../base/soundmanager2-nodebug'
|
require '../base/soundmanager2-nodebug'
|
||||||
require 'script!../base/tumblr'
|
require 'script!../base/tumblr'
|
||||||
require '../base/ui-bootstrap-tpls-0.4.0'
|
require '../base/ui-bootstrap-tpls-0.4.0'
|
||||||
require 'script!../base/underscore'
|
|
||||||
|
|
||||||
require '../shared/init.coffee'
|
|
||||||
require '../shared/jquery-extensions'
|
|
||||||
require '../shared/layout.coffee'
|
|
||||||
require '../shared/pfm-angular-marked'
|
require '../shared/pfm-angular-marked'
|
||||||
require '../shared/pfm-angular-sanitize'
|
require '../shared/pfm-angular-sanitize'
|
||||||
require 'script!../shared/underscore-extensions'
|
require '../shared/init.coffee'
|
||||||
|
|
||||||
|
|
||||||
ponyfm = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'angularytics', 'ngSanitize', 'hc.marked']
|
ponyfm = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'angularytics', 'ngSanitize', 'hc.marked']
|
||||||
|
|
|
@ -14,6 +14,17 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
require 'script!../base/jquery-2.0.2'
|
||||||
|
require '../base/jquery.timeago'
|
||||||
|
require '../base/soundmanager2-nodebug'
|
||||||
|
require './favourite.coffee'
|
||||||
|
|
||||||
|
require 'script!../base/underscore'
|
||||||
|
require '../shared/layout.coffee'
|
||||||
|
require 'script!../shared/underscore-extensions'
|
||||||
|
|
||||||
|
|
||||||
$('.timeago').timeago()
|
$('.timeago').timeago()
|
||||||
|
|
||||||
loaderDef = new $.Deferred()
|
loaderDef = new $.Deferred()
|
|
@ -14,6 +14,12 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
require 'script!../base/underscore'
|
||||||
|
require './jquery-extensions'
|
||||||
|
require './layout.coffee'
|
||||||
|
require 'script!./underscore-extensions'
|
||||||
|
|
||||||
def = new $.Deferred()
|
def = new $.Deferred()
|
||||||
|
|
||||||
pfm.soundManager = def.promise()
|
pfm.soundManager = def.promise()
|
||||||
|
|
|
@ -62,7 +62,12 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{!! Assets::scriptIncludes('embed') !!}
|
@if (Config::get("app.debug"))
|
||||||
|
<script src="http://localhost:61999/build/scripts/embed.js"></script>
|
||||||
|
<script src="http://localhost:61999/webpack-dev-server.js"></script>
|
||||||
|
@else
|
||||||
|
<script src="/build/scripts/embed.js"></script>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if(config('ponyfm.google_analytics_id'))
|
@if(config('ponyfm.google_analytics_id'))
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -16,10 +16,13 @@ module.exports = {
|
||||||
jQuery: "jquery"
|
jQuery: "jquery"
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
entry: './resources/assets/scripts/app/app.coffee',
|
entry: {
|
||||||
|
app: './resources/assets/scripts/app/app.coffee',
|
||||||
|
embed: './resources/assets/scripts/embed/embed.coffee'
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: __dirname + '/public',
|
path: __dirname + '/public',
|
||||||
filename: './build/scripts/app.js'
|
filename: './build/scripts/[name].js'
|
||||||
// publicPath should be defined in the dev config!
|
// publicPath should be defined in the dev config!
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|
Loading…
Reference in a new issue