Skip to content

Commit

Permalink
Cleanup node package require for webpackConfigLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
justin808 committed Apr 26, 2017
1 parent 566e2a8 commit 3cea6dc
Show file tree
Hide file tree
Showing 12 changed files with 64,106 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
const webpack = require('webpack');
const { resolve } = require('path');
const ManifestPlugin = require('webpack-manifest-plugin');
const webpackConfigLoader = require('react-on-rails').default.webpackConfigLoader; // eslint-disable-line import/no-unresolved

const { env, paths, publicPath } = webpackConfigLoader(resolve('..', 'config', 'webpack'));
const webpackConfigLoader = require('react-on-rails/node_package/lib/webpackConfigLoader').default;
const configPath = resolve('..', 'config', 'webpack');
const { env, paths, publicPath } = webpackConfigLoader(configPath);

const devBuild = env !== 'production';

Expand Down
5 changes: 0 additions & 5 deletions node_package/src/ReactOnRails.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import serverRenderReactComponent from './serverRenderReactComponent';
import buildConsoleReplay from './buildConsoleReplay';
import createReactElement from './createReactElement';
import Authenticity from './Authenticity';
import webpackConfigLoader from './webpackConfigLoader';
import context from './context';

const ctx = context();
Expand Down Expand Up @@ -223,10 +222,6 @@ ctx.ReactOnRails = {
resetOptions() {
this.options = Object.assign({}, DEFAULT_OPTIONS);
},

webpackConfigLoader(configPath) {
return webpackConfigLoader.configLoader(configPath);
},
};

ctx.ReactOnRails.resetOptions();
Expand Down
36 changes: 18 additions & 18 deletions node_package/src/webpackConfigLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ const { env } = require('process');
const { safeLoad } = require('js-yaml');
const { readFileSync } = require('fs');

export default {
configLoader(configPath) {
const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[env.NODE_ENV];
const configLoader = (configPath) => {
const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[env.NODE_ENV];

const devServerConfig = join(configPath, 'development.server.yml');
const devServer = safeLoad(readFileSync(devServerConfig, 'utf8')).development;
const devServerConfig = join(configPath, 'development.server.yml');
const devServer = safeLoad(readFileSync(devServerConfig, 'utf8')).development;

if (env.REACT_ON_RAILS_ENV === 'HOT') {
devServer.enabled = true;
}
const productionBuild = env.NODE_ENV === 'production';
if (env.REACT_ON_RAILS_ENV === 'HOT') {
devServer.enabled = true;
}
const productionBuild = env.NODE_ENV === 'production';

const publicPath = !productionBuild && devServer.enabled ?
`http://${devServer.host}:${devServer.port}/` : `/${paths.assets}/`;
const publicPath = !productionBuild && devServer.enabled ?
`http://${devServer.host}:${devServer.port}/` : `/${paths.assets}/`;

return {
devServer,
env,
paths,
publicPath,
};
},
return {
devServer,
env,
paths,
publicPath,
};
};

export default configLoader;
1 change: 1 addition & 0 deletions spec/dummy/app/assets/webpack/app-bundle.css

Large diffs are not rendered by default.

Loading

0 comments on commit 3cea6dc

Please sign in to comment.