Hello!
I'm trying to build my first extension for Flarum and just started with the Quick start guide found here: http://flarum.org/docs/extend/start/
The first part is working where the plugin echos back "Hello World!". However for the next section its not working as expected. It seems to fail when bootstrapping the JS file that Gulp transpiled. I can access the forum but it immediately stops working showing me a red error message "Something went wrong while trying to load the full version of this site."
I've got this in my bootstrap.php file:
<?php
use Flarum\Event\ConfigureClientView;
use Illuminate\Contracts\Events\Dispatcher;
return function(Dispatcher $events){
$events->listen(ConfigureClientView::class, function (ConfigureClientView $event) {
if ($event->isForum()) {
$event->addAssets(__DIR__ .'/js/forum/dist/extension.js');
$event->addBootstrapper('whatx/hello-world/main');
}
});
};
If I comment out these lines:
// $event->addAssets(__DIR__ .'/js/forum/dist/extension.js');
// $event->addBootstrapper('whatx/hello-world/main');
Like this it works, no error but obviously plugin isnt doing anything.
Project structure looks like this:
workbench/
├── whatx-hello-world/
│ ├── bootstrap.php
│ ├── composer.json
└──── js/
├── Gulpfile.js
├── package.json
├── node_modules/
├── src/
├── main.js
├── dist/
├── extension.js
In my root dir (forum) composer.json I've got this:
"require":
......
"whatx/flarum-hello-world": "*@dev"
},
"repositories":[
{
"type": "path",
"url": "workbench/*/"
}
]
workbench/whatx-hello-world/composer.json
{
"name": "whatx/flarum-hello-world",
"description": "Say hello to the world!",
"type": "flarum-extension",
"require": {
"flarum/core": "^0.1.0-beta.6"
},
"extra": {
"flarum-extension": {
"title": "Hello World"
}
}
}
workbench/whatx-hello-world/js/forum/Gulpfile.js
var flarum = require('flarum-gulp');
flarum({
modules: {
'whatx/hello-world': [
'src/**/*.js'
]
}
});
workbench/whatx-hello-world/js/forum/package.json
{
"private": true,
"devDependencies": {
"gulp": "^3.8.11",
"flarum-gulp": "^0.2.0"
}
}
workbench/whatx-hello-world/js/forum/src/main.js
app.initializers.add('whatx-hello-world', function() {
alert('Hello, world!');
});
Transpiled code in dist folder:
System.register('whatx/hello-world/main', [], function (_export) {
'use strict';
return {
setters: [],
execute: function () {
app.initializers.add('whatx-hello-world', function () {
alert('Hello, world!');
});
}
};
});
No error message is being generated in console, the only error message is the one specified above.
I've also tried changing permissions and owner of my workbench dir without success. If this is a permission problem, what are the recommended permissions to use?
If anyone could help me with this I would be really thankful!