Skip to content

Commit

Permalink
Fix webpack config merging for production build and watch.
Browse files Browse the repository at this point in the history
  • Loading branch information
strarsis committed Jan 13, 2021
1 parent dec3f8a commit 902f9f0
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions resources/assets/build/webpack.config.js
Expand Up @@ -13,6 +13,18 @@ const ESLintPlugin = require('eslint-webpack-plugin');
const desire = require('./util/desire');
const config = require('./config');

const mergeConfig = {
module: {
rules: {
test: 'match',
use: {
loader: 'match',
options: 'replace',
},
},
},
};

const assetsFilenames = (config.enabled.cacheBusting) ? config.cacheBusting : '[name]';

let webpackConfig = {
Expand Down Expand Up @@ -182,7 +194,7 @@ let webpackConfig = {
/* eslint-disable global-require */ /** Let's only load dependencies as needed */

if (config.enabled.optimize) {
webpackConfig = merge(webpackConfig, require('./webpack.config.optimize'));
webpackConfig = mergeWithRules(mergeConfig)(require('./webpack.config.optimize'), webpackConfig);
}

if (config.enabled.cacheBusting) {
Expand All @@ -201,7 +213,7 @@ if (config.enabled.cacheBusting) {

if (config.enabled.watcher) {
webpackConfig.entry = require('./util/addHotMiddleware')(webpackConfig.entry);
webpackConfig = merge(webpackConfig, require('./webpack.config.watch'));
webpackConfig = mergeWithRules(mergeConfig)(require('./webpack.config.watch'), webpackConfig);
}

/**
Expand All @@ -214,14 +226,4 @@ if (config.enabled.watcher) {
* ability to change certain options.
*/

module.exports = mergeWithRules({
module: {
rules: {
test: 'match',
use: {
loader: 'match',
options: 'replace',
},
},
},
})( webpackConfig, desire(`${__dirname}/webpack.config.preset`) ? desire(`${__dirname}/webpack.config.preset`) : {} )
module.exports = mergeWithRules(mergeConfig)( webpackConfig, desire(`${__dirname}/webpack.config.preset`) ? desire(`${__dirname}/webpack.config.preset`) : {} )

0 comments on commit 902f9f0

Please sign in to comment.