|
1 | 1 | import gulp from "gulp"; |
2 | 2 | import rimraf from "gulp-rimraf"; |
| 3 | +import webpack from "webpack"; |
3 | 4 | import preprocess from "gulp-preprocess"; |
4 | 5 | import cssMin from "gulp-cssmin"; |
5 | | -import browserify from "browserify"; |
6 | | -import to5ify from "6to5ify"; |
7 | | -import streamify from "gulp-streamify"; |
8 | | -import source from "vinyl-source-stream"; |
9 | 6 | import scss from "gulp-sass"; |
10 | 7 | import fs from "fs"; |
11 | 8 | import mime from "mime-types"; |
|
18 | 15 | STATIC_DATA_FILE = `${ SOURCE_DIR }/cls/${ APP_NAME }/StaticData.cls`, |
19 | 16 | context = { |
20 | 17 | package: pkg |
| 18 | + }, |
| 19 | + webpackConfig = { |
| 20 | + context: `${ __dirname }`, |
| 21 | + entry: { |
| 22 | + "index": `${ SOURCE_DIR }/static/js/index.js` |
| 23 | + }, |
| 24 | + output: { |
| 25 | + path: `${ BUILD_DIR }/static/js`, |
| 26 | + filename: `[name].js` |
| 27 | + }, |
| 28 | + module: { |
| 29 | + loaders: [ |
| 30 | + { |
| 31 | + test: /\.js$/, |
| 32 | + exclude: /node_modules/, |
| 33 | + loader: `babel-loader`, |
| 34 | + query: { |
| 35 | + presets: [`es2015`] |
| 36 | + } |
| 37 | + } |
| 38 | + ] |
| 39 | + } |
21 | 40 | }; |
22 | 41 |
|
23 | 42 | function getAllFiles (dir) { |
@@ -66,14 +85,12 @@ gulp.task("etc", ["clean"], () => { |
66 | 85 | .pipe(gulp.dest(BUILD_DIR + "/static")); |
67 | 86 | }); |
68 | 87 |
|
69 | | -gulp.task("js", ["clean"], () => { |
70 | | - return browserify(`${ SOURCE_DIR }/static/js/index.js`, { debug: true }) |
71 | | - .transform(to5ify) |
72 | | - .bundle() |
73 | | - .on(`error`, (err) => { console.error(err); }) |
74 | | - .pipe(source("index.js")) |
75 | | - .pipe(streamify(preprocess({ context: context }))) |
76 | | - .pipe(gulp.dest(`${ BUILD_DIR }/static/js`)); |
| 88 | +gulp.task("js", ["clean"], (done) => { |
| 89 | + webpack(webpackConfig, (err, stats) => { |
| 90 | + if (err) throw new Error(err); |
| 91 | + console.log(stats.toString()); |
| 92 | + done(err); |
| 93 | + }); |
77 | 94 | }); |
78 | 95 |
|
79 | 96 | gulp.task("css", ["clean"], () => { |
|
0 commit comments