glitchier-soc/config/webpack/configuration.js
Koala Yeung b1f14a1c7f Streamline javascript translation by improving translationRunner (#2808)
* package.json: Add "build:*" targets

* Improve react-intl-translations-manager workflow.
  * Added "build:production" to build production bundle.
  * Added "build:development" to build development bundle.

* Fix json translation files

* Run `yarn manage:translations` to fix translation files.
* Fix `pl.json` for syntax error.

* translationRunner: auto detect existing languages

* Auto detect existing rfc5646 language tag in *.json filenames
  in `app/javascript/mastodon/locale` folder. No need to manually
  define every new language in the languages array here.

* translationRunner: add more functionality

* Allow script user to specify language code to check.
* Added available language check.
* Added --force flag to force creation of unexists language.
* Added --help flag and help messages.

* gitignore: ignore npm-debug.log

* Fix webpack error if NODE_ENV is not defined

Default to use 'development' in config/webpack/configuration.js
2017-05-06 04:05:38 +02:00

26 lines
1 KiB
JavaScript

// Common configuration for webpacker loaded from config/webpack/paths.yml
const { join, resolve } = require('path')
const { env } = require('process')
const { safeLoad } = require('js-yaml')
const { readFileSync } = require('fs')
const configPath = resolve('config', 'webpack')
const loadersDir = join(__dirname, 'loaders')
const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[env.NODE_ENV || 'development']
const devServer = safeLoad(readFileSync(join(configPath, 'development.server.yml'), 'utf8'))[env.NODE_ENV || 'development']
// Compute public path based on environment and CDN_HOST in production
const ifHasCDN = env.CDN_HOST !== undefined && env.NODE_ENV === 'production'
const devServerUrl = `http://${devServer.host}:${devServer.port}/${paths.entry}/`
const publicUrl = ifHasCDN ? `${env.CDN_HOST}/${paths.entry}/` : `/${paths.entry}/`
const publicPath = env.NODE_ENV !== 'production' ? devServerUrl : publicUrl
module.exports = {
devServer,
env,
paths,
loadersDir,
publicUrl,
publicPath
}