react-on-rails
Advanced tools
Comparing version 9.0.0-beta.6 to 9.0.0-beta.7
@@ -21,3 +21,3 @@ # Change Log | ||
gem "webpacker", git: "https://github.com/shakacode/webpacker.git", | ||
branch: "issue-464-merge-webpacker-lite-into-webpacker" | ||
branch: "issue-464-merge-webpacker-lite-into-webpacker-v2" | ||
``` | ||
@@ -27,6 +27,32 @@ | ||
You will need to rename the following object properties: | ||
- hotReloadingUrl ==> devServerUrl | ||
- hotReloadingHostname ==> devServerHost | ||
- hotReloadingPort ==> devServerPort | ||
- webpackOutputPath ==> output.path | ||
- webpackPublicOutputDir ==> output.publicPath | ||
- hotReloadingUrl ==> output.publicPathWithHost | ||
- hotReloadingHostname ==> settings.dev_server.host | ||
- hotReloadingPort ==> settings.dev_server.port | ||
- hmr ==> settings.dev_server.hmr | ||
- manifest ==> Remove this one. We use the default for Webpack of manifest.json | ||
- env ==> Use `const { env } = require('process'); | ||
- devBuild ==> Use `const devBuild = process.env.NODE_ENV !== 'production'; | ||
- Edit your Webpack.config files: | ||
- Change your Webpack output to be like: | ||
``` | ||
// Leading slash is necessary | ||
publicPath: `/${output.publicPath}`, | ||
path: output.path, | ||
``` | ||
- Change your ManifestPlugin definition to include publicPath | ||
``` | ||
output: { | ||
// Name comes from the entry section. | ||
filename: '[name]-[chunkhash].js', | ||
publicPath: output.publicPath, | ||
path: output.path, | ||
}, | ||
``` | ||
- Find your `webpacker_lite.yml` and rename it to `webpacker.yml` | ||
@@ -37,5 +63,3 @@ - Add a section like this under your development env: | ||
host: localhost | ||
port: 8080 | ||
https: false | ||
# Can be enabled by export WEBPACKER_HMR=TRUE in env | ||
port: 3035 | ||
hmr: false | ||
@@ -67,4 +91,17 @@ ``` | ||
### [9.0.0-beta.7] | ||
- Depend on updated rails/webpacker in branch | ||
gem "webpacker", git: "https://github.com/shakacode/webpacker.git", | ||
branch: "issue-464-merge-webpacker-lite-into-webpacker-v2" | ||
### [9.0.0-beta.6] | ||
- Change "hot" to "hmr". | ||
### [9.0.0-beta.3] | ||
- Fix typo on webpackConfigLoader.js | ||
### [9.0.0-beta.3] | ||
- Fix typo on webpackConfigLoader.js | ||
@@ -695,4 +732,8 @@ ### [9.0.0-beta.2] | ||
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/rails-webpacker...9.0.0-beta.3 | ||
[9.0.0]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.3...master | ||
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/rails-webpacker...9.0.0-beta.7 | ||
[9.0.0]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.7...master | ||
[9.0.0-beta.7]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.7...9.0.0-beta.6 | ||
[9.0.0-beta.6]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.6...9.0.0-beta.5 | ||
[9.0.0-beta.5]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.5...9.0.0-beta.4 | ||
[9.0.0-beta.4]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.4...9.0.0-beta.3 | ||
[9.0.0-beta.3]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.3...9.0.0-beta.2 | ||
@@ -699,0 +740,0 @@ [9.0.0-beta.2]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.2...9.0.0-beta.1 |
{ | ||
"name": "react-on-rails", | ||
"version": "9.0.0-beta.6", | ||
"version": "9.0.0-beta.7", | ||
"description": "react-on-rails JavaScript for react_on_rails Ruby gem", | ||
@@ -5,0 +5,0 @@ "main": "node_package/lib/ReactOnRails.js", |
@@ -8,66 +8,49 @@ /** | ||
*/ | ||
const { join, resolve } = require('path'); | ||
const { env } = require('process'); | ||
const { safeLoad } = require('js-yaml'); | ||
const { readFileSync } = require('fs'); | ||
const MANIFEST = 'manifest.json'; | ||
const DEFAULT_PUBLIC_OUTPUT_PATH = 'packs'; | ||
const DEFAULT_DEV_SERVER_HOST = 'localhost'; | ||
const DEFAULT_DEV_SERVER_PORT = '8080'; | ||
const DEFAULT_DEV_SERVER_HTTPS = false; | ||
const DEFAULT_DEV_SERVER_HMR = false; | ||
function removeOuterSlashes(string) { | ||
return string.replace(/^\/*/, '').replace(/\/*$/, ''); | ||
} | ||
function formatPublicPath(host = '', path = '') { | ||
let formattedHost = removeOuterSlashes(host); | ||
if (formattedHost && !/^http/i.test(formattedHost)) { | ||
formattedHost = `//${formattedHost}`; | ||
} | ||
const formattedPath = removeOuterSlashes(path); | ||
return `${formattedHost}/${formattedPath}/`; | ||
} | ||
/** | ||
* @param configPath, location where webpacker.yml will be found | ||
* Return values are consistent with Webpacker's js helpers | ||
* @returns {{ | ||
* devBuild, | ||
* hmrReloadingEnabled, | ||
* devServerEnabled, | ||
* devServerHost, | ||
* devServerPort, | ||
* devServerUrl, | ||
* manifest, | ||
* webpackOutputPath, | ||
* webpackPublicOutputDir | ||
* }} | ||
settings, | ||
resolvedModules, | ||
output: { path, publicPath, publicPathWithHosts } | ||
}} | ||
*/ | ||
const configLoader = (configPath) => { | ||
const env = process.env; | ||
// Some test environments might not have the NODE_ENV set, so we'll have fallbacks. | ||
const configEnv = (process.env.NODE_ENV || process.env.RAILS_ENV || 'development'); | ||
const ymlConfigPath = join(configPath, 'webpacker.yml'); | ||
const configuration = safeLoad(readFileSync(ymlConfigPath, 'utf8'))[configEnv]; | ||
const devServerValues = configuration.dev_server; | ||
const devBuild = configEnv !== 'production'; | ||
const devServerHost = devServerValues && (devServerValues.host || DEFAULT_DEV_SERVER_HOST); | ||
const devServerPort = devServerValues && (devServerValues.port || DEFAULT_DEV_SERVER_PORT); | ||
const devServerHttps = devServerValues && (devServerValues.https || DEFAULT_DEV_SERVER_HTTPS); | ||
const devServerHmr = devServerValues && (devServerValues.hmr || DEFAULT_DEV_SERVER_HMR); | ||
const settings = safeLoad(readFileSync(ymlConfigPath, 'utf8'))[configEnv]; | ||
// NOTE: Rails path is hard coded to `/public` | ||
const webpackPublicOutputDir = configuration.public_output_path || | ||
DEFAULT_PUBLIC_OUTPUT_PATH; | ||
const webpackOutputPath = resolve(configPath, '..', 'public', webpackPublicOutputDir); | ||
const output = { | ||
// Next line differs from the webpacker definition as we use the configPath to create | ||
// the relative path. | ||
path: resolve(configPath, '..', 'public', settings.public_output_path), | ||
publicPath: `/${settings.public_output_path}/`.replace(/([^:]\/)\/+/g, '$1'), | ||
publicPathWithHost: formatPublicPath(env.ASSET_HOST, settings.public_output_path), | ||
}; | ||
const manifest = MANIFEST; | ||
const devServerEnabled = !!devServerValues; | ||
const hmrReloadingEnabled = !!devServerHmr || env.WEBPACKER_HMR === 'TRUE'; | ||
let devServerUrl = null; | ||
if (devServerValues) { | ||
devServerUrl = `http${devServerHttps ? 's' : ''}://${devServerHost}:${devServerPort}`; | ||
} | ||
return { | ||
devBuild, | ||
hmrReloadingEnabled, | ||
devServerEnabled, | ||
devServerHost, | ||
devServerPort, | ||
devServerUrl, | ||
manifest, | ||
webpackOutputPath, | ||
webpackPublicOutputDir, | ||
settings, | ||
output, | ||
}; | ||
@@ -74,0 +57,0 @@ }; |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
143231
3
883