Skip to content

Commit

Permalink
Support extends for the Webpack configuration object in webpack.project
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinweber committed Jul 6, 2018
1 parent 9093fa5 commit f86cd0f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const WEBPACK_CONFIG_BASE = {
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
// Webpack v4: `query` replaces `options`
query: require('./babel.config.js'),
}, {
loader: 'eslint-loader',
Expand All @@ -40,7 +39,7 @@ const WEBPACK_CONFIG_BASE = {
},
}],
}, {
// The "?" allows you use both file formats: .css and .scss
// The "?" allows you to use both file formats: .css and .scss
test: /\.s?css$/,
exclude: /node_modules/,
use: [
Expand Down
9 changes: 8 additions & 1 deletion ui.apps/src/main/webpack.core/internals/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const path = require('path');

const CONFIG = require('./../../webpack.project');
const WEBPACK_CONFIG_BASE = path.resolve(__dirname, './webpack.config.base.js');

CONFIG.webpack.extends = path.join(__dirname, './webpack.config.base.js');
if (typeof CONFIG.webpack.extends === 'string') {
// Convert string into array so we can apply our base config
CONFIG.webpack.extends = [CONFIG.webpack.extends];
}

CONFIG.webpack.extends = CONFIG.webpack.extends || [];
CONFIG.webpack.extends.push(WEBPACK_CONFIG_BASE);

module.exports = CONFIG.webpack;
10 changes: 10 additions & 0 deletions ui.apps/src/main/webpack.project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ const AEM = {
* WEBPACK
*/
const WEBPACK = {
/**
* Optional: You can base this config on another Webpack config.
* More details: https://github.com/webpack-contrib/config-loader/blob/master/docs/EXTENDS.md
* NOTE: We haven't thoroughly tested this feature yet.
* It's unclear how other Webpack configs will behave when combined with our base configuration.
*/
// extends: [
// path.join(__dirname, '../webpack.config.shared.js'),
// ],

/*
* Here we can add specify as many entries as we want. One entry results in one output file.
* The property name ("components") defines how the target file is named, e.g. 'main' results in 'main.bundle.js'.
Expand Down

0 comments on commit f86cd0f

Please sign in to comment.