forked from Alex/Pterodactyl-Panel
Remove gulp, move entirely to webpack
This commit is contained in:
parent
e84d2d6ae1
commit
8673a061ac
100
gulpfile.js
100
gulpfile.js
@ -1,100 +0,0 @@
|
||||
const babel = require('gulp-babel');
|
||||
const concat = require('gulp-concat');
|
||||
const cssmin = require('gulp-cssmin');
|
||||
const del = require('del');
|
||||
const exec = require('child_process').exec;
|
||||
const gulp = require('gulp');
|
||||
const gulpif = require('gulp-if');
|
||||
const postcss = require('gulp-postcss');
|
||||
const rev = require('gulp-rev');
|
||||
const uglify = require('gulp-uglify-es').default;
|
||||
const webpackStream = require('webpack-stream');
|
||||
const webpackConfig = require('./webpack.config.js');
|
||||
|
||||
const argv = require('yargs')
|
||||
.default('production', false)
|
||||
.argv;
|
||||
|
||||
const paths = {
|
||||
manifest: './public/assets',
|
||||
assets: './public/assets/{css,scripts}/*.{css,js}',
|
||||
styles: {
|
||||
src: './resources/assets/styles/main.css',
|
||||
dest: './public/assets/css',
|
||||
},
|
||||
scripts: {
|
||||
src: './resources/assets/scripts/**/*.{js,vue}',
|
||||
watch: ['./resources/assets/scripts/**/*.{js,vue}', './resources/lang/locales.js'],
|
||||
dest: './public/assets/scripts',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Build un-compiled CSS into a minified version.
|
||||
*/
|
||||
function styles() {
|
||||
return gulp.src(paths.styles.src)
|
||||
.pipe(postcss([
|
||||
require('postcss-import'),
|
||||
require('tailwindcss')('./tailwind.js'),
|
||||
require('postcss-preset-env')({stage: 0}),
|
||||
require('autoprefixer'),
|
||||
]))
|
||||
.pipe(gulpif(argv.production, cssmin()))
|
||||
.pipe(concat('bundle.css'))
|
||||
.pipe(rev())
|
||||
.pipe(gulp.dest(paths.styles.dest))
|
||||
.pipe(rev.manifest(paths.manifest + '/manifest.json', {merge: true, base: paths.manifest}))
|
||||
.pipe(gulp.dest(paths.manifest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides watchers.
|
||||
*/
|
||||
function watch() {
|
||||
gulp.watch(['./resources/assets/styles/**/*.css'], gulp.series(function cleanStyles() {
|
||||
return del(['./public/assets/css/**/*.css']);
|
||||
}, styles));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the language files to be consumed by front end.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
function i18n() {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec('php artisan vue-i18n:generate', {}, (err, stdout, stderr) => {
|
||||
return err ? reject(err) : resolve({ stdout, stderr });
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the routes file to be used in Vue files.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
function routes() {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec('php artisan ziggy:generate resources/assets/scripts/helpers/ziggy.js', {}, (err, stdout, stderr) => {
|
||||
return err ? reject(err) : resolve({ stdout, stderr });
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup unused versions of hashed assets.
|
||||
*/
|
||||
function clean() {
|
||||
return del([paths.assets]);
|
||||
}
|
||||
|
||||
exports.clean = clean;
|
||||
exports.i18n = i18n;
|
||||
exports.routes = routes;
|
||||
exports.styles = styles;
|
||||
exports.watch = watch;
|
||||
|
||||
gulp.task('components', gulp.parallel(i18n, routes));
|
||||
gulp.task('default', gulp.series(clean, i18n, routes, styles));
|
@ -1,5 +1,8 @@
|
||||
const path = require('path');
|
||||
const CleanPlugin = require('clean-webpack-plugin');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
const ShellPlugin = require('webpack-shell-plugin');
|
||||
const UglifyJsPLugin = require('uglifyjs-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
@ -8,12 +11,13 @@ module.exports = {
|
||||
performance: {
|
||||
hints: false,
|
||||
},
|
||||
entry: {
|
||||
bundle: './resources/assets/scripts/app.js',
|
||||
},
|
||||
// Passing an array loads them all but only exports the last.
|
||||
entry: ['./resources/assets/styles/main.css', './resources/assets/scripts/app.js'],
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'public/assets/scripts'),
|
||||
filename: 'bundle-[chunkhash].js',
|
||||
path: path.resolve(__dirname, 'public/assets'),
|
||||
filename: 'bundle-[chunkhash].min.js',
|
||||
publicPath: '/assets/',
|
||||
crossOriginLoading: 'anonymous',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@ -34,11 +38,29 @@ module.exports = {
|
||||
include: [
|
||||
path.resolve(__dirname, 'resources/assets/scripts'),
|
||||
],
|
||||
use: [{
|
||||
loader: 'babel-loader',
|
||||
options: {babelrc: true}
|
||||
}]
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'resources/assets/styles'),
|
||||
],
|
||||
use: ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: ['css-loader', {
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
ident: 'postcss',
|
||||
plugins: [
|
||||
require('postcss-import'),
|
||||
require('postcss-preset-env')({stage: 0}),
|
||||
require('tailwindcss')('./tailwind.js'),
|
||||
require('autoprefixer'),
|
||||
]
|
||||
},
|
||||
}],
|
||||
}),
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
@ -48,6 +70,16 @@ module.exports = {
|
||||
extensions: ['*', '.js', '.vue', '.json']
|
||||
},
|
||||
plugins: [
|
||||
new CleanPlugin(path.resolve(__dirname, 'public/assets')),
|
||||
new ShellPlugin({
|
||||
onBuildStart: [
|
||||
'php artisan vue-i18n:generate',
|
||||
'php artisan ziggy:generate resources/assets/scripts/helpers/ziggy.js',
|
||||
],
|
||||
}),
|
||||
new ExtractTextPlugin('bundle-[chunkhash].min.css', {
|
||||
allChunks: true,
|
||||
}),
|
||||
new UglifyJsPLugin({
|
||||
include: [
|
||||
path.resolve(__dirname, 'resources/assets/scripts'),
|
||||
|
Loading…
Reference in New Issue
Block a user