diff --git a/tasks/build.js b/tasks/build.js index dbaa8b0..ee7d95c 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -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', diff --git a/tasks/scripts.js b/tasks/scripts.js index 23b99d3..3bfe419 100644 --- a/tasks/scripts.js +++ b/tasks/scripts.js @@ -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({ diff --git a/tasks/xdLib.js b/tasks/xdLib.js new file mode 100644 index 0000000..cceb8b6 --- /dev/null +++ b/tasks/xdLib.js @@ -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`)); +});