Skip to content

Commit

Permalink
chore: add lib build step
Browse files Browse the repository at this point in the history
  • Loading branch information
Joabesv committed Feb 7, 2024
1 parent 3aa8041 commit 8de8904
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import './styles'
import './pages'
import './images'
import './chromereload'
import './xdLib'

gulp.task('build', gulp.series(
'clean',
'manifest',
'xdLib',
'scripts',
'styles',
'pages',
Expand Down
2 changes: 1 addition & 1 deletion tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ gulp.task("scripts", (cb) => {
"src/scripts/**/**/*.js",
"src/main.js",
"src/utils/**/*.js",
"src/lib/**/*.js",
// "src/lib/**/*.js",
])
.pipe(
plumber({
Expand Down
58 changes: 58 additions & 0 deletions tasks/xdLib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import gulp from "gulp";
import webpack from "webpack";
import gulpWebpack from "webpack-stream";
import { log, colors } from "gulp-util";
import named from "vinyl-named";
import rename from "gulp-rename";

import args from "./lib/args";

gulp.task("xdLib", () => {
const tmp = {};
return gulp
.src("src/lib/**/*.js")
.pipe(named())
.pipe(
rename(function (path) {
tmp[path.basename] = path;
})
)
.pipe(
gulpWebpack(
{
output: {
filename: "[name].js",
},
plugins: [new webpack.optimize.UglifyJsPlugin()],
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/,
},
],
},
},
webpack,
(err, stats) => {
if (err) return;
log(
`Finished '${colors.cyan("scripts")}'`,
stats.toString({
chunks: false,
colors: true,
cached: false,
children: false,
})
);
}
)
)
.pipe(
rename(function (path) {
path.dirname = tmp[path.basename].dirname;
})
)
.pipe(gulp.dest(`dist/${args.vendor}/lib`));
});

0 comments on commit 8de8904

Please sign in to comment.