-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.js
51 lines (43 loc) · 1.05 KB
/
webpack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
/**
* External dependencies
*/
import {
src,
dest,
} from 'gulp';
import webpack from 'webpack';
import webpackStream from 'webpack-stream';
/**
* Internal dependencies
*/
import {
bundlerNotActive,
logStreamFail,
} from '../helper/log.js';
import {
lintScripts,
startScriptStringReplace,
} from '../scripts.js';
import webpackConfig from '../../webpack.config.js';
import { paths } from '../constants.js';
/**
* Bundles script using webpack bundler.
*
* Configure webpack using `webpack.config.js` in the root directory.
*
* @param {function} done Function to call when async processes finish.
* @return {NodeJS.ReadWriteStream} NodeJS stream.
*/
export const bundleScripts = ( done ) => {
const config = webpackConfig;
if ( Object.keys( config.entry ).length < 1 ) {
return bundlerNotActive( true, done() );
}
return src( paths.scripts.bundlerSrc )
.pipe( logStreamFail() )
.pipe( lintScripts() )
.pipe( webpackStream( config, webpack ) )
.pipe( startScriptStringReplace() )
.pipe( dest( paths.scripts.bundlerDest ) );
};