Guest User

Untitled

a guest
Sep 19th, 2020
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const { argv } = require('yargs');
  3. const merge = require('webpack-merge');
  4.  
  5. const desire = require('./util/desire');
  6.  
  7. const userConfig = merge(desire(`${__dirname}/../config`), desire(`${__dirname}/../config-local`));
  8.  
  9. const isProduction = !!((argv.env && argv.env.production) || argv.p);
  10. const rootPath = (userConfig.paths && userConfig.paths.root)
  11.   ? userConfig.paths.root
  12.   : process.cwd();
  13.  
  14. const config = merge({
  15.   open: true,
  16.   copy: 'images/**/*',
  17.   proxyUrl: 'http://localhost:3000',
  18.   cacheBusting: '[name]_[hash]',
  19.   paths: {
  20.     root: rootPath,
  21.     assets: path.join(rootPath, 'resources/assets'),
  22.     dist: path.join(rootPath, 'dist'),
  23.   },
  24.   enabled: {
  25.     sourceMaps: !isProduction,
  26.     optimize: isProduction,
  27.     cacheBusting: isProduction,
  28.     watcher: !!argv.watch,
  29.   },
  30.   watch: [],
  31. }, userConfig);
  32.  
  33. module.exports = merge(config, {
  34.   env: Object.assign({ production: isProduction, development: !isProduction }, argv.env),
  35.   publicPath: `${config.publicPath}/${path.basename(config.paths.dist)}/`,
  36.   manifest: {},
  37. });
  38.  
  39. if (process.env.NODE_ENV === undefined) {
  40.   process.env.NODE_ENV = isProduction ? 'production' : 'development';
  41. }
  42.  
  43. /**
  44.  * If your publicPath differs between environments, but you know it at compile time,
  45.  * then set SAGE_DIST_PATH as an environment variable before compiling.
  46.  * Example:
  47.  *   SAGE_DIST_PATH=/wp-content/themes/sage/dist/ yarn build:production
  48.  */
  49. if (process.env.SAGE_DIST_PATH) {
  50.   module.exports.publicPath = process.env.SAGE_DIST_PATH;
  51. }
  52.  
  53. /**
  54.  * If you don't know your publicPath at compile time, then uncomment the lines
  55.  * below and use WordPress's wp_localize_script() to set SAGE_DIST_PATH global.
  56.  * Example:
  57.  *   wp_localize_script('sage/main.js', 'SAGE_DIST_PATH', get_theme_file_uri('dist/'))
  58.  */
  59. // Object.keys(module.exports.entry).forEach(id =>
  60. //   module.exports.entry[id].unshift(path.join(__dirname, 'helpers/public-path.js')));
  61.  
RAW Paste Data Copied