Skip to content

Instantly share code, notes, and snippets.

@hindmost
hindmost / cra-browserext-boilerplate-config-overrides-sample.js
Created April 22, 2020 18:44
cra-browserext-boilerplate: config-overrides.js sample
module.exports = function override(config, env) {
...
return config;
}
@hindmost
hindmost / cra-browserext-boilerplate-webpack.config-structure.js
Created April 22, 2020 18:46
cra-browserext-boilerplate: webpack.config.js structure
...
const paths = require('./paths');
...
module.exports = function(webpackEnv) {
...
return {
...
entry: [
isEnvDevelopment &&
require.resolve('react-dev-utils/webpackHotDevClient'),
@hindmost
hindmost / cra-browserext-boilerplate-webpack.config-entrypoint-old.js
Created April 22, 2020 18:48
cra-browserext-boilerplate: webpack.config.js - entrypoint - origin
...
entry: [ paths.appIndexJs ],
...
@hindmost
hindmost / cra-browserext-boilerplate-webpack.config-entrypoint-new.js
Created April 22, 2020 18:49
cra-browserext-boilerplate: webpack.config.js - entrypoint - new
...
entry: {
popup: paths.appIndexJs,
options: paths.appSrc + '/options.js',
background: paths.appSrc + '/background.js',
content: paths.appSrc + '/content.js'
},
...
@hindmost
hindmost / cra-browserext-boilerplate-config-overrides-entrypoint.js
Created April 22, 2020 18:50
cra-browserext-boilerplate: config-overrides.js - entrypoint
const paths = require('react-scripts/config/paths');
...
module.exports = function override(config, env) {
config.entry = {
popup: paths.appIndexJs,
options: paths.appSrc + '/options.js',
background: paths.appSrc + '/background.js',
content: paths.appSrc + '/content.js'
}
...
@hindmost
hindmost / cra-browserext-boilerplate-webpack.config-output-old.js
Created April 22, 2020 18:51
cra-browserext-boilerplate: webpack.config.js - output - origin
...
output: {
...
filename: isEnvProduction
? 'static/js/[name].[contenthash:8].js'
: isEnvDevelopment && 'static/js/bundle.js',
...
},
...
@hindmost
hindmost / cra-browserext-boilerplate-config-overrides-output.js
Created April 22, 2020 18:54
cra-browserext-boilerplate: config-overrides.js - output
module.exports = function override(config, env) {
...
config.output.filename = 'static/js/[name].js';
...
}
@hindmost
hindmost / cra-browserext-boilerplate-config-overrides-optimization.js
Created April 22, 2020 18:56
cra-browserext-boilerplate: config-overrides.js - optimization
module.exports = function override(config, env) {
...
config.optimization.splitChunks = {
cacheGroups: {default: false}
};
config.optimization.runtimeChunk = false;
...
}
@hindmost
hindmost / cra-browserext-boilerplate-webpack.config-html-plugin-old.js
Created April 22, 2020 18:58
cra-browserext-boilerplate: webpack.config.js - html-webpack-plugin - origin
...
const HtmlWebpackPlugin = require('html-webpack-plugin');
...
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: paths.appHtml,
minify: {
removeComments: true,
collapseWhitespace: true,
@hindmost
hindmost / cra-browserext-boilerplate-webpack.config-html-plugin-new.js
Created April 22, 2020 19:00
cra-browserext-boilerplate: webpack.config.js - html-webpack-plugin - new
new HtmlWebpackPlugin({
inject: true,
template: paths.appHtml,
filename: 'popup.html',
chunks: ['popup'],
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,