From 0316c7cf723a6dcc0480a504484beafc95fc1b48 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 8 Oct 2020 08:43:00 -0600 Subject: [PATCH] Move out of webpacker.yml --- package.json | 1 - webpack/config/webpacker.yml | 72 ------------------------------------ webpack/configuration.js | 23 +++++++++--- 3 files changed, 17 insertions(+), 79 deletions(-) delete mode 100644 webpack/config/webpacker.yml diff --git a/package.json b/package.json index 48ec2e95b..cbce6f327 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "intl-messageformat-parser": "^6.0.0", "intl-pluralrules": "^1.1.1", "is-nan": "^1.2.1", - "js-yaml": "^3.13.1", "lodash": "^4.7.11", "mark-loader": "^0.1.6", "marky": "^1.2.1", diff --git a/webpack/config/webpacker.yml b/webpack/config/webpacker.yml deleted file mode 100644 index f84149eef..000000000 --- a/webpack/config/webpacker.yml +++ /dev/null @@ -1,72 +0,0 @@ -# Note: You must restart bin/webpack-dev-server for changes to take effect - -default: &default - source_path: app - public_root_path: static - public_output_path: packs - cache_path: tmp/cache/webpacker - check_yarn_integrity: false - webpack_compile_output: false - - # Additional paths webpack should lookup modules - # ['app/assets', 'engine/foo/app/assets'] - resolved_paths: [] - - # Reload manifest.json on all requests so we reload latest compiled packs - cache_manifest: false - - # Extract and emit a css file - extract_css: true - - static_assets_extensions: - - .jpg - - .jpeg - - .png - - .tiff - - .ico - - .svg - - .gif - - .eot - - .otf - - .ttf - - .woff - - .woff2 - - extensions: - - .mjs - - .js - - .sass - - .scss - - .css - - .module.sass - - .module.scss - - .module.css - - .png - - .svg - - .gif - - .jpeg - - .jpg - -development: - <<: *default - - compile: true - -test: - <<: *default - - # CircleCI precompiles packs prior to running the tests. - # Also avoids race conditions in parallel_tests. - compile: false - - # Compile test packs to a separate directory - public_output_path: packs-test - -production: - <<: *default - - # Production depends on precompilation of packs prior to booting for performance. - compile: false - - # Cache manifest.json for performance - cache_manifest: true diff --git a/webpack/configuration.js b/webpack/configuration.js index 703119e3a..5aa818993 100644 --- a/webpack/configuration.js +++ b/webpack/configuration.js @@ -1,17 +1,28 @@ -// Common configuration for webpacker loaded from config/webpacker.yml - const { join } = require('path'); const { env } = require('process'); -const { safeLoad } = require('js-yaml'); -const { readFileSync } = require('fs'); -const configPath = join(__dirname, 'config', 'webpacker.yml'); -const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV]; +const settings = { + source_path: 'app', + public_root_path: 'static', + public_output_path: getPublicOutputPath(), + cache_path: 'tmp/cache/webpacker', + resolved_paths: [], + static_assets_extensions: [ '.jpg', '.jpeg', '.png', '.tiff', '.ico', '.svg', '.gif', '.eot', '.otf', '.ttf', '.woff', '.woff2' ], + extensions: [ '.mjs', '.js', '.sass', '.scss', '.css', '.module.sass', '.module.scss', '.module.css', '.png', '.svg', '.gif', '.jpeg', '.jpg' ], +}; function removeOuterSlashes(string) { return string.replace(/^\/*/, '').replace(/\/*$/, ''); } +function getPublicOutputPath() { + if (env.NODE_ENV === 'test') { + return 'packs-test'; + } + + return 'packs'; +} + function formatPublicPath(host = '', path = '') { let formattedHost = removeOuterSlashes(host); if (formattedHost && !/^http/i.test(formattedHost)) {