GWebpackBuilder
Webpack project builder. When it starts, webpack configuration file is loaded first if available. And then, it is overridden with BuildConfig.moduleOptions.webpack settings if available. Finally, the entry points and output settings are overridden again with BuildConfig.src, BuildConfig.dest, BuildConfig.outFile.
Builder specific Options
Available options for BuildConfig.buildOptions:
Option | Type | Default | Description |
---|---|---|---|
webpackConfig | string | undefined | Path to webpack configuration file. |
Notes
- If BuildConfig.src is specified, it will override the 'entry' value of webpack configuration. A string or an array of string is allowed, but it cannot specify multiple entry points. To configure multiple entry points, use moduleOptions.webpack option or separate webpack configuration file.
- If BuildConfig.dest is specified, it will override output.path of webpack configuration.
- If BuildConfig.outFile is specified, it will override output.filename of webpack configuration.
- To enable sourceMap, add devtool option to webpack configuration file. For more details, refer to webpack documentation on Devtool{:target="_blank"}.
Example
const tron = require('gulp-tron');
const path = require('path');
const srcRoot = 'assets';
const destRoot = '_build';
// build configuration
const webpack = {
name: 'webpack',
builder: 'GWebpackBuilder',
// This will finally override the webpack configuration
// src: [path.join(srcRoot, 'scripts/ts/app.ts')],
// dest: path.join(destRoot, 'jss'),
// outFile: 'sample-ts.js',
buildOptions: {
webpackConfig: 'webpack.config.js'
},
moduleOptions: {
// webpack configuration comes here. This will override webpack configuration file.
webpack: {
// entry: path.resolve(srcRoot, 'scripts/ts/greet.ts'),
// mode: 'production',
// devtool: 'source-map',
// module: {
// rules: [
// {
// test: /\.tsx?$/,
// use: 'ts-loader',
// exclude: /node_modules/
// }
// ],
// },
// resolve: {
// extensions: ['.tsx', '.ts', '.js']
// },
// output: {
// filename: 'bundle.js',
// path: path.resolve(destRoot, 'js')
// },
},
}
};