mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-06-05 21:59:25 +02:00
use webpack directly and npm scripts more in general
This commit is contained in:
54
gulpfile.js
54
gulpfile.js
@ -1,50 +1,14 @@
|
||||
const { dest, series, src } = require('gulp');
|
||||
const { dest, src } = require('gulp');
|
||||
|
||||
const del = require('del');
|
||||
const replace = require('gulp-replace');
|
||||
const webpack = require('webpack-stream');
|
||||
|
||||
const PACKAGE = require('./package.json');
|
||||
|
||||
const FOLDER_SOURCE = './source'
|
||||
const FOLDER_BUILD = './build';
|
||||
|
||||
let mode = 'development';
|
||||
|
||||
|
||||
function clean(cb) {
|
||||
del(FOLDER_BUILD);
|
||||
cb();
|
||||
}
|
||||
|
||||
const eventsLoaderOutputPath = PACKAGE.name + '/front/events-loader';
|
||||
const eventsLoaderInputPath = FOLDER_SOURCE + '/' + PACKAGE.name + '/front/events-loader.js';
|
||||
|
||||
function bundleFrontend() {
|
||||
return src(FOLDER_SOURCE + '/' + PACKAGE.name + '/front/events-loader.js')
|
||||
.pipe(webpack({
|
||||
mode,
|
||||
entry: {
|
||||
[eventsLoaderOutputPath]: eventsLoaderInputPath,
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
},
|
||||
}))
|
||||
.pipe(dest(FOLDER_BUILD));
|
||||
}
|
||||
|
||||
function copyBackend() {
|
||||
return src([
|
||||
FOLDER_SOURCE + '/**/*.php',
|
||||
FOLDER_SOURCE + '/**/*.txt'
|
||||
])
|
||||
.pipe(dest(FOLDER_BUILD));
|
||||
}
|
||||
|
||||
function injectMetadata() {
|
||||
return src([
|
||||
FOLDER_BUILD + '/' + eventsLoaderOutputPath + '.js',
|
||||
FOLDER_BUILD + '/' + PACKAGE.name + '/front/events-loader.js',
|
||||
FOLDER_BUILD + '/' + PACKAGE.name + '/' + PACKAGE.name + '.php',
|
||||
FOLDER_BUILD + '/' + PACKAGE.name + '/includes/constants.php',
|
||||
FOLDER_BUILD + '/' + PACKAGE.name + '/readme.txt'
|
||||
@ -63,18 +27,4 @@ function injectMetadata() {
|
||||
.pipe(dest('.'));
|
||||
}
|
||||
|
||||
exports.front = bundleFrontend;
|
||||
exports.copy = copyBackend;
|
||||
exports.inject = injectMetadata;
|
||||
|
||||
const build = series(clean, bundleFrontend, copyBackend, injectMetadata);
|
||||
|
||||
const buildDev = series((cb) => { mode = 'development'; cb(); }, build);
|
||||
|
||||
const buildProd = series((cb) => { mode = 'production'; cb(); }, build);
|
||||
|
||||
|
||||
exports.clean = clean;
|
||||
exports.dev = buildDev;
|
||||
exports.default = buildDev;
|
||||
exports.prod = buildProd;
|
||||
|
Reference in New Issue
Block a user