mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
cc4eda6478
refs https://github.com/TryGhost/Team/issues/1664 - overrides webpack config to generate single script for publishing - adds custom scripts for dev and production mode
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
const rewire = require('rewire');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const defaults = rewire('react-scripts/scripts/build.js');
|
|
let config = defaults.__get__('config');
|
|
|
|
config.optimization.splitChunks = {
|
|
cacheGroups: {
|
|
default: false
|
|
}
|
|
};
|
|
|
|
config.optimization.runtimeChunk = false;
|
|
|
|
// JS: Save built file in `/umd`
|
|
config.output.filename = '../umd/comments-ui.min.js';
|
|
|
|
// CSS: Remove MiniCssPlugin from list of plugins
|
|
config.plugins = config.plugins.filter(plugin => !(plugin instanceof MiniCssExtractPlugin));
|
|
// CSS: replaces all MiniCssExtractPlugin.loader with style-loader to embed CSS in JS
|
|
config.module.rules[1].oneOf = config.module.rules[1].oneOf.map((rule) => {
|
|
if (!Object.prototype.hasOwnProperty.call(rule, 'use')) {
|
|
return rule;
|
|
}
|
|
return Object.assign({}, rule, {
|
|
use: rule.use.map(options => (/mini-css-extract-plugin/.test(options.loader)
|
|
? {loader: require.resolve('style-loader'), options: {}}
|
|
: options))
|
|
});
|
|
});
|