diff --git a/bin/elm-app-cli.js b/bin/elm-app-cli.js index 40a8eaf1..a9e4d5c9 100755 --- a/bin/elm-app-cli.js +++ b/bin/elm-app-cli.js @@ -78,12 +78,15 @@ switch (script) { * @return {undefined} */ function help(version) { - console.log('\nUsage: elm-app \n'); + console.log(); + console.log('Usage: elm-app '); + console.log(); console.log('where is one of:'); - console.log( - ' build, start, test, eject, ' + elmCommands.join(', ') + '\n' - ); - console.log('\nElm ' + elmVersion + '\n'); + console.log(' build, start, test, eject, ' + elmCommands.join(', ')); + console.log(); + console.log(); + console.log('Elm ' + elmVersion); + console.log(); console.log( 'create-elm-app@' + version + ' ' + path.resolve(__dirname, '..') ); diff --git a/config/paths.js b/config/paths.js index b84c7343..d0dc96ba 100644 --- a/config/paths.js +++ b/config/paths.js @@ -15,6 +15,9 @@ const resolveApp = relativePath => path.resolve(appDirectory, relativePath); const explorer = cosmiconfig('elmapp'); const result = explorer.searchSync(appDirectory); const config = result ? result.config : loadElmJson(); +const id = x => x; +const configureWebpack = + typeof config.configureWebpack === 'function' ? config.configureWebpack : id; // WARNING: // We support config in elm.json only for legacy reasons. @@ -76,5 +79,6 @@ module.exports = { elm: require.resolve('elm/bin/elm'), publicUrl: getPublicUrl(config), servedPath: getServedPath(config), - proxy: config.proxy + proxy: config.proxy, + configureWebpack }; diff --git a/scripts/build.js b/scripts/build.js index 0662703a..fa0662f6 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -94,7 +94,9 @@ function build(previousFileSizes) { console.log(`Creating an optimized ${process.env.NODE_ENV} build...`); } - const compiler = webpack(config); + const compiler = webpack( + paths.configureWebpack(config, process.env.NODE_ENV) + ); return new Promise((resolve, reject) => { compiler.run((err, stats) => { if (err) { diff --git a/scripts/eject.js b/scripts/eject.js index e5a9d94b..f4bd1a24 100644 --- a/scripts/eject.js +++ b/scripts/eject.js @@ -82,12 +82,14 @@ function performEject(pkg) { // Update or create new package.json fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); - console.log('\nPlease wait for npm to install all required dependencies...'); + console.log(); + console.log('Please wait for npm to install all required dependencies...'); // Install npm packages spawn.sync('npm', ['install'], { stdio: 'inherit' }); - console.log(chalk.green('\nEjected successfully!')); + console.log(); + console.log(chalk.green('Ejected successfully!')); } // The following dependencies will be removed: diff --git a/scripts/start.js b/scripts/start.js index cc8b160b..fccb32da 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -160,7 +160,12 @@ choosePort(HOST, DEFAULT_PORT) const appName = path.basename(path.dirname(paths.elmJson)); const urls = prepareUrls(protocol, HOST, port); // Create a webpack compiler that is configured with custom messages. - const compiler = createCompiler(webpack, config, appName, urls); + const compiler = createCompiler( + webpack, + paths.configureWebpack(config, process.env.NODE_ENV), + appName, + urls + ); // Load proxy config const proxyConfig = prepareProxy(paths.proxy, paths.appPublic); // Serve webpack assets generated by the compiler over a web sever.