See https://github.com/flarum/core/pull/1367

* Replace gulp with webpack and npm scripts for JS compilation
* Set up Travis CI to commit compiled JS
* Restructure `js` directory; only one instance of npm, forum/admin are "submodules"
* Restructure `less` directory
This commit is contained in:
Toby Zerner 2018-06-20 13:35:48 +09:30 committed by GitHub
parent 96c96193e4
commit 6eae43688e
16 changed files with 4756 additions and 332 deletions

Binary file not shown.

View File

@ -2,4 +2,4 @@
.gitignore export-ignore
.travis.yml export-ignore
js/*/dist/*.js -diff
js/dist/* -diff

View File

@ -2,5 +2,5 @@
composer.phar
.DS_Store
Thumbs.db
bower_components
node_modules
node_modules
js/dist/*

View File

@ -0,0 +1,15 @@
language: minimal
sudo: false
cache:
directories:
- $HOME/.npm
jobs:
include:
- stage: build
if: branch = master AND type = push
script: curl -s https://raw.githubusercontent.com/flarum/core/master/.travis/build.sh | bash -s -
-k $encrypted_73644080ee09_key
-i $encrypted_73644080ee09_iv

View File

@ -9,10 +9,16 @@
* file that was distributed with this source code.
*/
use Flarum\Extend;
use Flarum\Statistics\Listener;
use Illuminate\Contracts\Events\Dispatcher;
return function (Dispatcher $events) {
$events->subscribe(Listener\AddClientAssets::class);
$events->subscribe(Listener\AddStatisticsData::class);
};
return [
(new Extend\Assets('admin'))
->js(__DIR__.'/js/dist/admin.js')
->asset(__DIR__.'/less/admin.less'),
function (Dispatcher $events) {
$events->subscribe(Listener\AddStatisticsData::class);
}
];

View File

@ -0,0 +1,10 @@
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from './src/admin';

View File

@ -1,10 +0,0 @@
var gulp = require('flarum-gulp');
gulp({
modules: {
'flarum/statistics': 'src/**/*.js'
},
files: [
'node_modules/frappe-charts/dist/frappe-charts.min.iife.js'
]
});

File diff suppressed because one or more lines are too long

View File

@ -1,10 +0,0 @@
{
"private": true,
"devDependencies": {
"gulp": "^3.9.1",
"flarum-gulp": "^0.2.0"
},
"dependencies": {
"frappe-charts": "0.0.8"
}
}

4700
extensions/statistics/js/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
{
"name": "@flarum/flarum-ext-statistics",
"version": "0.0.0",
"dependencies": {
"flarum-webpack-config": "^0.1.0-beta.8",
"frappe-charts": "0.0.8",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.7"
},
"scripts": {
"build": "webpack --mode production --progress",
"watch": "webpack --mode development --watch"
}
}

View File

@ -3,7 +3,7 @@ import { extend } from 'flarum/extend';
import DashboardPage from 'flarum/components/DashboardPage';
import StatisticsWidget from 'flarum/statistics/components/StatisticsWidget';
import StatisticsWidget from './components/StatisticsWidget';
app.initializers.add('flarum-statistics', () => {
extend(DashboardPage.prototype, 'availableWidgets', widgets => {

View File

@ -0,0 +1,3 @@
const config = require('flarum-webpack-config');
module.exports = config();

View File

@ -1,40 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Statistics\Listener;
use Flarum\Frontend\Event\Rendering;
use Illuminate\Contracts\Events\Dispatcher;
class AddClientAssets
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(Rendering::class, [$this, 'addAssets']);
}
/**
* @param Rendering $event
*/
public function addAssets(Rendering $event)
{
if ($event->isAdmin()) {
$event->addAssets([
__DIR__.'/../../js/admin/dist/extension.js',
__DIR__.'/../../less/admin/extension.less'
]);
$event->addBootstrapper('flarum/statistics/main');
}
}
}