Skip to content

Commit 58bc6b3

Browse files
committed
refactor: improve UIKit Webpack output
1 parent 26e886c commit 58bc6b3

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

packages/uikit-workshop/webpack.config.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const CopyPlugin = require('copy-webpack-plugin');
1313
const path = require('path');
1414
const argv = require('yargs').argv;
1515
const merge = require('webpack-merge');
16+
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
1617

1718
const cosmiconfig = require('cosmiconfig');
1819
const explorer = cosmiconfig('patternlab');
@@ -22,11 +23,12 @@ const defaultConfig = {
2223
buildDir: './dist',
2324
prod: argv.watch ? false : true, // or false for local dev
2425
sourceMaps: true,
26+
watch: argv.watch ? true : false,
2527
publicPath: './styleguide/',
2628
copy: [{ from: './src/images/**', to: 'images', flatten: true }],
2729
};
2830

29-
module.exports = function() {
31+
module.exports = function(apiConfig) {
3032
return new Promise(async resolve => {
3133
let customConfig = defaultConfig;
3234
let configToSearchFor;
@@ -44,7 +46,7 @@ module.exports = function() {
4446
}
4547

4648
// Allow external flags for modifying PL's prod mode, on top of the .patternlabrc config file
47-
const config = Object.assign({}, defaultConfig, customConfig);
49+
const config = Object.assign({}, defaultConfig, customConfig, apiConfig);
4850

4951
function getBabelConfig(isModern = false) {
5052
return {
@@ -127,6 +129,9 @@ module.exports = function() {
127129
];
128130

129131
const webpackConfig = {
132+
stats: {
133+
logging: 'none',
134+
},
130135
performance: {
131136
hints: false,
132137
},
@@ -215,8 +220,7 @@ module.exports = function() {
215220
],
216221
},
217222
cache: true,
218-
// mode: config.prod ? 'production' : 'development',
219-
mode: config.prod ? 'production' : 'development', // temp workaround till strange rendering issues with full `production` mode are switched on in Webpack
223+
mode: config.prod ? 'production' : 'development',
220224
optimization: {
221225
minimize: config.prod,
222226
occurrenceOrder: true,
@@ -250,6 +254,7 @@ module.exports = function() {
250254
: [],
251255
},
252256
plugins: [
257+
new FriendlyErrorsWebpackPlugin(),
253258
new CopyPlugin(config.copy),
254259
new NoEmitPlugin(['css/pattern-lab.js']),
255260
],
@@ -329,7 +334,7 @@ module.exports = function() {
329334
plugins: [
330335
// clear out the buildDir on every fresh Webpack build
331336
new CleanWebpackPlugin(
332-
argv.watch
337+
config.watch
333338
? []
334339
: [
335340
`${config.buildDir}/index.html`,

0 commit comments

Comments
 (0)