diff options
Diffstat (limited to 'config/webpack')
-rw-r--r-- | config/webpack/configuration.js | 28 | ||||
-rw-r--r-- | config/webpack/development.js | 12 | ||||
-rw-r--r-- | config/webpack/development.server.js | 14 | ||||
-rw-r--r-- | config/webpack/loaders/assets.js | 10 | ||||
-rw-r--r-- | config/webpack/loaders/babel.js | 6 | ||||
-rw-r--r-- | config/webpack/loaders/coffee.js | 4 | ||||
-rw-r--r-- | config/webpack/loaders/erb.js | 6 | ||||
-rw-r--r-- | config/webpack/loaders/sass.js | 12 | ||||
-rw-r--r-- | config/webpack/production.js | 20 | ||||
-rw-r--r-- | config/webpack/shared.js | 46 | ||||
-rw-r--r-- | config/webpack/test.js | 6 | ||||
-rw-r--r-- | config/webpack/translationRunner.js | 14 |
12 files changed, 89 insertions, 89 deletions
diff --git a/config/webpack/configuration.js b/config/webpack/configuration.js index e2f8d2d8b..922e8c517 100644 --- a/config/webpack/configuration.js +++ b/config/webpack/configuration.js @@ -1,20 +1,20 @@ // 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 { 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'] +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 +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, @@ -22,5 +22,5 @@ module.exports = { paths, loadersDir, publicUrl, - publicPath -} + publicPath, +}; diff --git a/config/webpack/development.js b/config/webpack/development.js index 398fcffe3..f6235f42e 100644 --- a/config/webpack/development.js +++ b/config/webpack/development.js @@ -1,16 +1,16 @@ // Note: You must restart bin/webpack-dev-server for changes to take effect -const merge = require('webpack-merge') -const sharedConfig = require('./shared.js') +const merge = require('webpack-merge'); +const sharedConfig = require('./shared.js'); module.exports = merge(sharedConfig, { devtool: 'cheap-module-eval-source-map', stats: { - errorDetails: true + errorDetails: true, }, output: { - pathinfo: true - } -}) + pathinfo: true, + }, +}); diff --git a/config/webpack/development.server.js b/config/webpack/development.server.js index 455daad2c..296df1504 100644 --- a/config/webpack/development.server.js +++ b/config/webpack/development.server.js @@ -1,9 +1,9 @@ // Note: You must restart bin/webpack-dev-server for changes to take effect -const { resolve } = require('path') -const merge = require('webpack-merge') -const devConfig = require('./development.js') -const { devServer, publicPath, paths } = require('./configuration.js') +const { resolve } = require('path'); +const merge = require('webpack-merge'); +const devConfig = require('./development.js'); +const { devServer, publicPath, paths } = require('./configuration.js'); module.exports = merge(devConfig, { devServer: { @@ -14,6 +14,6 @@ module.exports = merge(devConfig, { historyApiFallback: true, contentBase: resolve(paths.output, paths.entry), publicPath, - disableHostCheck: true - } -}) + disableHostCheck: true, + }, +}); diff --git a/config/webpack/loaders/assets.js b/config/webpack/loaders/assets.js index 595f073fc..643b3eeb0 100644 --- a/config/webpack/loaders/assets.js +++ b/config/webpack/loaders/assets.js @@ -1,4 +1,4 @@ -const { env, publicPath } = require('../configuration.js') +const { env, publicPath } = require('../configuration.js'); module.exports = { test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i, @@ -6,7 +6,7 @@ module.exports = { loader: 'file-loader', options: { publicPath, - name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]' - } - }] -} + name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]', + }, + }], +}; diff --git a/config/webpack/loaders/babel.js b/config/webpack/loaders/babel.js index e58d0633e..8cd9170a2 100644 --- a/config/webpack/loaders/babel.js +++ b/config/webpack/loaders/babel.js @@ -3,6 +3,6 @@ module.exports = { exclude: /node_modules/, loader: 'babel-loader', options: { - forceEnv: process.env.NODE_ENV || 'development' - } -} + forceEnv: process.env.NODE_ENV || 'development', + }, +}; diff --git a/config/webpack/loaders/coffee.js b/config/webpack/loaders/coffee.js index dae874249..416f787fe 100644 --- a/config/webpack/loaders/coffee.js +++ b/config/webpack/loaders/coffee.js @@ -1,4 +1,4 @@ module.exports = { test: /\.coffee(\.erb)?$/, - loader: 'coffee-loader' -} + loader: 'coffee-loader', +}; diff --git a/config/webpack/loaders/erb.js b/config/webpack/loaders/erb.js index 4cd7d6849..5b523f8d1 100644 --- a/config/webpack/loaders/erb.js +++ b/config/webpack/loaders/erb.js @@ -4,6 +4,6 @@ module.exports = { exclude: /node_modules/, loader: 'rails-erb-loader', options: { - runner: 'bin/rails runner' - } -} + runner: 'bin/rails runner', + }, +}; diff --git a/config/webpack/loaders/sass.js b/config/webpack/loaders/sass.js index 2cb0e759a..24abf1685 100644 --- a/config/webpack/loaders/sass.js +++ b/config/webpack/loaders/sass.js @@ -1,5 +1,5 @@ -const ExtractTextPlugin = require('extract-text-webpack-plugin') -const { env } = require('../configuration.js') +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const { env } = require('../configuration.js'); module.exports = { test: /\.(scss|sass|css)$/i, @@ -8,7 +8,7 @@ module.exports = { use: [ { loader: 'css-loader', options: { minimize: env.NODE_ENV === 'production' } }, 'postcss-loader', - 'sass-loader' - ] - }) -} + 'sass-loader', + ], + }), +}; diff --git a/config/webpack/production.js b/config/webpack/production.js index 261bfdd70..6969f04a8 100644 --- a/config/webpack/production.js +++ b/config/webpack/production.js @@ -2,10 +2,10 @@ /* eslint global-require: 0 */ -const webpack = require('webpack') -const merge = require('webpack-merge') -const CompressionPlugin = require('compression-webpack-plugin') -const sharedConfig = require('./shared.js') +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const CompressionPlugin = require('compression-webpack-plugin'); +const sharedConfig = require('./shared.js'); module.exports = merge(sharedConfig, { @@ -19,15 +19,15 @@ module.exports = merge(sharedConfig, { mangle: true, output: { - comments: false + comments: false, }, - sourceMap: true + sourceMap: true, }), new CompressionPlugin({ asset: '[path].gz[query]', algorithm: 'gzip', - test: /\.(js|css|svg|eot|ttf|woff|woff2)$/ - }) - ] -}) + test: /\.(js|css|svg|eot|ttf|woff|woff2)$/, + }), + ], +}); diff --git a/config/webpack/shared.js b/config/webpack/shared.js index 008218808..4986ea24d 100644 --- a/config/webpack/shared.js +++ b/config/webpack/shared.js @@ -3,24 +3,24 @@ /* eslint global-require: 0 */ /* eslint import/no-dynamic-require: 0 */ -const webpack = require('webpack') -const { basename, dirname, join, relative, resolve } = require('path') -const { sync } = require('glob') -const ExtractTextPlugin = require('extract-text-webpack-plugin') -const ManifestPlugin = require('webpack-manifest-plugin') -const extname = require('path-complete-extname') -const { env, paths, publicPath, loadersDir } = require('./configuration.js') +const webpack = require('webpack'); +const { basename, dirname, join, relative, resolve } = require('path'); +const { sync } = require('glob'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const ManifestPlugin = require('webpack-manifest-plugin'); +const extname = require('path-complete-extname'); +const { env, paths, publicPath, loadersDir } = require('./configuration.js'); -const extensionGlob = `**/*{${paths.extensions.join(',')}}*` -const packPaths = sync(join(paths.source, paths.entry, extensionGlob)) +const extensionGlob = `**/*{${paths.extensions.join(',')}}*`; +const packPaths = sync(join(paths.source, paths.entry, extensionGlob)); module.exports = { entry: packPaths.reduce( (map, entry) => { - const localMap = map - const namespace = relative(join(paths.source, paths.entry), dirname(entry)) - localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry) - return localMap + const localMap = map; + const namespace = relative(join(paths.source, paths.entry), dirname(entry)); + localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry); + return localMap; }, {} ), @@ -28,11 +28,11 @@ module.exports = { filename: '[name].js', chunkFilename: '[name]-[chunkhash].js', path: resolve(paths.output, paths.entry), - publicPath + publicPath, }, module: { - rules: sync(join(loadersDir, '*.js')).map(loader => require(loader)) + rules: sync(join(loadersDir, '*.js')).map(loader => require(loader)), }, plugins: [ @@ -41,25 +41,25 @@ module.exports = { new ManifestPlugin({ fileName: paths.manifest, publicPath, writeToFileEmit: true }), new webpack.optimize.CommonsChunkPlugin({ name: 'common', - minChunks: 2 - }) + minChunks: 2, + }), ], resolve: { extensions: paths.extensions, modules: [ resolve(paths.source), - resolve(paths.node_modules) - ] + resolve(paths.node_modules), + ], }, resolveLoader: { - modules: [paths.node_modules] + modules: [paths.node_modules], }, node: { // Called by http-link-header in an API we never use, increases // bundle size unnecessarily - Buffer: false - } -} + Buffer: false, + }, +}; diff --git a/config/webpack/test.js b/config/webpack/test.js index e002d0cdc..6b2b073bb 100644 --- a/config/webpack/test.js +++ b/config/webpack/test.js @@ -1,6 +1,6 @@ // Note: You must restart bin/webpack-dev-server for changes to take effect -const merge = require('webpack-merge') -const sharedConfig = require('./shared.js') +const merge = require('webpack-merge'); +const sharedConfig = require('./shared.js'); -module.exports = merge(sharedConfig, {}) +module.exports = merge(sharedConfig, {}); diff --git a/config/webpack/translationRunner.js b/config/webpack/translationRunner.js index 7c1f96877..8d2fb4893 100644 --- a/config/webpack/translationRunner.js +++ b/config/webpack/translationRunner.js @@ -7,16 +7,16 @@ const testRFC5626 = function (reRFC5646) { if (!language.match(reRFC5646)) { throw new Error('Not RFC5626 name'); } - } -} + }; +}; const testAvailability = function (availableLanguages) { return function (language) { if ((argv.force !== true) && availableLanguages.indexOf(language) < 0) { throw new Error('Not an available language'); } - } -} + }; +}; const validateLanguages = function (languages, validators) { let invalidLanguages = languages.reduce((acc, language) => { @@ -41,7 +41,7 @@ const validateLanguages = function (languages, validators) { console.log(`\nUse yarn "manage:translations -- --help" for usage information\n`); process.exit(1); } -} +}; const printHelpMessages = function () { console.log( @@ -62,13 +62,13 @@ to input multiple languages, separate them with space. Available languages: ${availableLanguages} `); -} +}; // parse arguments const argv = require('minimist')(process.argv.slice(2), { 'boolean': [ 'force', - 'help' + 'help', ], 'alias': { 'f': 'force', |