mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 07:42:48 +08:00
Webpack (#4)
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:
parent
96c96193e4
commit
6eae43688e
BIN
extensions/statistics/.deploy.enc
Normal file
BIN
extensions/statistics/.deploy.enc
Normal file
Binary file not shown.
2
extensions/statistics/.gitattributes
vendored
2
extensions/statistics/.gitattributes
vendored
|
@ -2,4 +2,4 @@
|
|||
.gitignore export-ignore
|
||||
.travis.yml export-ignore
|
||||
|
||||
js/*/dist/*.js -diff
|
||||
js/dist/* -diff
|
||||
|
|
4
extensions/statistics/.gitignore
vendored
4
extensions/statistics/.gitignore
vendored
|
@ -2,5 +2,5 @@
|
|||
composer.phar
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
bower_components
|
||||
node_modules
|
||||
node_modules
|
||||
js/dist/*
|
||||
|
|
15
extensions/statistics/.travis.yml
Normal file
15
extensions/statistics/.travis.yml
Normal 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
|
|
@ -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);
|
||||
}
|
||||
];
|
||||
|
|
10
extensions/statistics/js/admin.js
Normal file
10
extensions/statistics/js/admin.js
Normal 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';
|
|
@ -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'
|
||||
]
|
||||
});
|
264
extensions/statistics/js/admin/dist/extension.js
vendored
264
extensions/statistics/js/admin/dist/extension.js
vendored
File diff suppressed because one or more lines are too long
|
@ -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
4700
extensions/statistics/js/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
extensions/statistics/js/package.json
Normal file
14
extensions/statistics/js/package.json
Normal 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"
|
||||
}
|
||||
}
|
|
@ -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 => {
|
3
extensions/statistics/js/webpack.config.js
Normal file
3
extensions/statistics/js/webpack.config.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
const config = require('flarum-webpack-config');
|
||||
|
||||
module.exports = config();
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user