How to use the react-scripts/config/paths.appBuild 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 micthiesen / spotify-my-slack / client / scripts / start.js View on Github external
// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
  process.exit(1);
}

const configDevelopment = configFactory("development");
const configProduction = configFactory("production");
const config = configDevelopment;
config.entry = configProduction.entry;
config.output.path = configProduction.output.path;
config.plugins = config.plugins.filter(
  p => p.constructor.name !== "HotModuleReplacementPlugin"
);

fs.emptyDirSync(paths.appBuild);
const compiler = webpack(config);
compiler.watch({ ignored: [paths.appNodeModules] }, (err, stats) => {
  let messages;
  if (err) {
    let errMessage = err.message;

    messages = formatWebpackMessages({
      errors: [errMessage],
      warnings: []
    });
  } else {
    messages = formatWebpackMessages(
      stats.toJson({ all: false, warnings: true, errors: true })
    );
  }
  if (messages.errors.length) {
github Talend / component-runtime / component-form / component-form-demo / src / main / frontend / webpack.config.js View on Github external
: {};

// This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file.
module.exports = {
  // Don't attempt to continue if there are any errors.
  bail: true,
  // We generate sourcemaps in production. This is slow but gives good results.
  // You can exclude the *.map files from the build during deployment.
  devtool: shouldUseSourceMap ? 'source-map' : false,
  // In production, we only want to load the polyfills and the app code.
  entry: [require.resolve('react-scripts/config/polyfills'), paths.appIndexJs],
  output: {
    // The build folder.
    path: paths.appBuild,
    // Generated JS file names (with nested folders).
    // There will be one main bundle, and one file per asynchronous chunk.
    // We don't currently advertise code splitting but Webpack supports it.
    filename: 'static/js/[name].[chunkhash:8].js',
    chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
    // We inferred the "public path" (such as / or /my-project) from homepage.
    publicPath: publicPath,
    // Point sourcemap entries to original disk location (format as URL on Windows)
    devtoolModuleFilenameTemplate: info =>
      path
        .relative(paths.appSrc, info.absoluteResourcePath)
        .replace(/\\/g, '/'),
  },
  resolve: {
    // This allows you to set a fallback for where Webpack should look for modules.
    // We placed these paths second because we want `node_modules` to "win"
github timarney / react-app-rewired / scripts / build.js View on Github external
process.env.NODE_ENV = 'production'
var override = require('../config-overrides')

var rimrafSync = require('rimraf').sync
var webpack = require('webpack')
var config = require('react-scripts/config/webpack.config.prod')

config = override(config)

var paths = require('react-scripts/config/paths')
rimrafSync(paths.appBuild + '/*')

console.log('Creating an optimized production build...')
webpack(config).run(function (err, stats) {
  if (err) {
    console.error('Failed to create a production build. Reason:')
    console.error(err.message || err)
    process.exit(1)
  }

  console.log('Compiled successfully.')
})
github goblin-laboratory / cra-multi-page-template / react-app-rewire-entry.js View on Github external
Object.keys(entry).map(name => {
        const reg = new RegExp(`^\\/${name}\\.html`);
        rewrites.push({ from: reg, to: `/${paths.appBuild}/${name}.html` });
        return name;
      });
      config.historyApiFallback.rewrites = rewrites;
github ghondar / crassa / react-scripts-wrapper-paths.js View on Github external
if(hasSlash && !needsSlash) return inputPath.substr(0, inputPath.length - 1)
  else if(!hasSlash && needsSlash) return `${inputPath}/`
  else return inputPath
}

function getServedPath(publicUrl) {
  const servedUrl = publicUrl ? url.parse(publicUrl).pathname : '/'

  return ensureSlash(servedUrl, true)
}

paths.dotenv = existsSync(appDotEnv) ? appDotEnv : paths.dotenv
paths.appPath = appRootPath + '/'
paths.appPublic = appPublic
paths.appHtml = appPublic + '/index.html'
paths.appBuild = appBuild
paths.appPackageJson = appPackage
paths.yarnLockFile = appRootPath + '/yarn.lock'
paths.appSrc = appSrc
paths.appIndexJs = appSrc + '/index.js'
paths.proxySetup = appSrc + '/setupProxy.js'
paths.testsSetup = appSrc + '/setupTests'
paths.appNodeModules = appNodeModules
paths.servedPath = homepage ? getServedPath(homepage) : '/'
paths.publicUrl = homepage || ''

module.exports = paths