Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const path = require( 'path' );
// webpack.config.prod.js checks this.
process.env.NODE_ENV = 'production';
// Load the create-react-app config.
const webpackConfigProd = require( 'react-scripts/config/webpack.config.prod' );
// Modify the config according to our needs.
const babelLoader = webpackConfigProd.module.loaders
.find( loader => loader.loader === 'babel' );
if ( ! babelLoader ) {
console.error( webpackConfigProd.module.loaders );
throw new Error( 'Couldn\'t find the babel loader config.' );
}
babelLoader.query.plugins = ( babelLoader.query.plugins || [] )
.filter( pluginName => pluginName !== 'lodash' )
.concat( 'lodash' );
console.log( 'Added lodash babel plugin to build' );
if ( process.env.WPCOM_BUILD ) {
babelLoader.query.plugins.push( path.resolve(
__dirname, '..', 'src', 'lib', 'babel-replace-config-import.js'
) );
console.log( 'Added config override for WP.com build' );
}
#!/usr/bin/env node
const path = require( 'path' );
// webpack.config.prod.js checks this.
process.env.NODE_ENV = 'production';
// Load the create-react-app config.
const webpackConfigProd = require( 'react-scripts/config/webpack.config.prod' );
// Modify the config according to our needs.
const babelLoader = webpackConfigProd.module.loaders
.find( loader => loader.loader === 'babel' );
if ( ! babelLoader ) {
console.error( webpackConfigProd.module.loaders );
throw new Error( 'Couldn\'t find the babel loader config.' );
}
babelLoader.query.plugins = ( babelLoader.query.plugins || [] )
.filter( pluginName => pluginName !== 'lodash' )
.concat( 'lodash' );
console.log( 'Added lodash babel plugin to build' );
if ( process.env.WPCOM_BUILD ) {
babelLoader.query.plugins.push( path.resolve(
__dirname, '..', 'src', 'lib', 'babel-replace-config-import.js'
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');