src/index.js in hauler-0.2.0 vs src/index.js in hauler-0.3.0

- old
+ new

@@ -19,25 +19,35 @@ const config = utils.mergeProjectConfig(projectDefaults, projectConfig); return config; }; } -export function getConfig(env: string, railsRoot?: string) { - if (railsRoot != null) { - utils.setRailsRoot(railsRoot); - } - +export function getConfig(env: string, railsRoot: string, appName: string) { + utils.setRailsRoot(railsRoot); const configFactory = getConfigFactory(); - return configFactory(env); + const config = configFactory(env); + return Object.assign(config, { appName }); } -export function getDevServerConfig(env: string, railsRoot?: string): WebpackDevServerConfig { - const config = getConfig(env, railsRoot); +export function getDevServerConfig( + env: string, railsRoot: string, appName: string +): WebpackDevServerConfig { + const config = getConfig(env, railsRoot, appName); return utils.extractDevServerConfig(config); } -export function getCompilerConfig(env: string, railsRoot?: string): WebpackConfig { - const config = getConfig(env, railsRoot); - return utils.extractCompilerConfig(config); +export function getCompilerConfig( + env: string, railsRoot: string, appName: string +): WebpackConfig { + const config = getConfig(env, railsRoot, appName); + const compilerConfig = utils.extractCompilerConfig(config); + if (env !== 'development') { + return compilerConfig; + } + + const devServerConfig = utils.extractDevServerConfig(config); + return Object.assign(compilerConfig, { + entry: utils.makeHotReloadableEntries(compilerConfig.entry, devServerConfig.publicPath), + }); } export { getEnvName } from './utils';