How to use the react-scripts/config/webpack.config.prod.plugins function in react-scripts

To help you get started, we’ve selected a few react-scripts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redgeoff / mson-react / scripts / build-analyzer.js View on Github external
// Performs a production build and generates a report so that large dependencies can be identified.
//
// Usage: node build-analyzer
//
//  Then open build/report.html in a browser
//
// Source: https://github.com/facebook/create-react-app/issues/3518#issue-277616195

process.env.NODE_ENV = "production"
var BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
  .BundleAnalyzerPlugin

const webpackConfigProd = require("react-scripts/config/webpack.config.prod")

webpackConfigProd.plugins.push(
  new BundleAnalyzerPlugin({
    analyzerMode: "static",
    reportFilename: "report.html",
  })
)

require("react-scripts/scripts/build")
github fabric8-ui / fabric8-ui / talamer / packages / scripts / scripts / analyze.js View on Github external
process.env.NODE_ENV = 'production';
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');

require('../lib/rewire-scripts')(true);

const webpackConfigProd = require('react-scripts/config/webpack.config.prod');

webpackConfigProd.plugins.push(
  new BundleAnalyzerPlugin({
    analyzerMode: 'static',
    reportFilename: 'report.html',
  }),
);

require('react-scripts/scripts/build');
github rafi16jan / rapyd-framework / client / scripts / build.js View on Github external
//require('module-alias/register');
process.env.NODE_ENV = 'production';
process.env.NODE_PATH = './src';

const config = require('react-scripts/config/webpack.config.prod');
const OfflinePlugin = require('offline-plugin');

//config.plugins.splice(5, 1);

config.output.publicPath = '';

config.plugins.push(new OfflinePlugin({appShell: 'index.html', ServiceWorker: {prefetchRequest: {mode: 'no-cors'}, events: true}, AppCache: {events: true}, relativePaths: true}));


config.resolve.alias['react'] = require('path').join(__dirname, '../src/react.js');//'preact-compat';
config.resolve.alias['react-dom'] = require('path').join(__dirname, '../src/react-dom.js');//'preact-compat';
config.resolve.alias['pouchdb-promise'] = require('path').join(__dirname, '../node_modules/pouchdb-promise/lib/index.js');

config.module.rules.push({test: /framework7\.min\.css$/, loader: 'string-replace-loader', options: {search: '\#9e9e9e', replace: '#009688', flags: 'g'}});
//config.module.rules.push({test: /sw\.js$/, loader: 'string-replace-loader', options: {search: ',e.respondWith\(f\)', replace: ';try{e.respondWith(f)}catch(error){}'}});

require('react-scripts/scripts/build');
github CakeDC / mixer / webpack.config.prod.js View on Github external
let reactScriptsConfig = require('react-scripts/config/webpack.config.prod');
let path = require('path');
let fs = require('fs');

let appDirectory = fs.realpathSync(process.cwd());
function resolveApp(relativePath) {
    return path.resolve(appDirectory, relativePath);
}

let ExtractTextPlugin = require('extract-text-webpack-plugin');

const cssFilename = 'css/[name].css';

module.exports = Object.assign({}, reactScriptsConfig, {
    devtool: false,
    plugins: reactScriptsConfig.plugins
        .map(function (plugin, index) {
            if (index === 4) {
                return new ExtractTextPlugin(cssFilename);
            }

            return plugin;
        })
        .filter((plugin, index) => [0, 1, 5, 6].indexOf(index) === -1),
    entry: reactScriptsConfig.entry
        .map(entry => entry.includes('src' + path.sep + 'index.js') ? resolveApp('src' + path.sep + 'React' + path.sep + 'index.js') : entry),
    output: Object.assign({}, reactScriptsConfig.output, {
        path: resolveApp('webroot'),
        filename: 'js/[name].js',
        chunkFilename: 'js/[name].chunk.js',
    })
});