Skip to content

Instantly share code, notes, and snippets.

@jkroepke
Created October 14, 2019 18:19
Show Gist options
  • Save jkroepke/37b6378661b094dd734acd4751b6be98 to your computer and use it in GitHub Desktop.
Save jkroepke/37b6378661b094dd734acd4751b6be98 to your computer and use it in GitHub Desktop.
const WebpackFilePreprocessorPlugin = require('@jkroepke/webpack-file-preprocessor-plugin');
const minifyHtml = require('html-minifier').minify;
module.exports = config => {
config.plugins.push(
new WebpackFilePreprocessorPlugin({
pattern: /\.(svg)$/,
process: source => minifyHtml(source.toString(), {
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
}),
})
);
config.plugins.push(
new WebpackFilePreprocessorPlugin({
pattern: /\.(json)$/,
process: source => JSON.stringify(JSON.parse(source)),
})
);
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment