Skip to content

Commit ebf674b

Browse files
authored
Merge pull request #311 from halfzebra/enable-webpack-config-overrides
Enable webpack config overrides
2 parents 588fe31 + 92b5308 commit ebf674b

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

bin/elm-app-cli.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ switch (script) {
7878
* @return {undefined}
7979
*/
8080
function help(version) {
81-
console.log('\nUsage: elm-app <command>\n');
81+
console.log();
82+
console.log('Usage: elm-app <command>');
83+
console.log();
8284
console.log('where <command> is one of:');
83-
console.log(
84-
' build, start, test, eject, ' + elmCommands.join(', ') + '\n'
85-
);
86-
console.log('\nElm ' + elmVersion + '\n');
85+
console.log(' build, start, test, eject, ' + elmCommands.join(', '));
86+
console.log();
87+
console.log();
88+
console.log('Elm ' + elmVersion);
89+
console.log();
8790
console.log(
8891
'create-elm-app@' + version + ' ' + path.resolve(__dirname, '..')
8992
);

config/paths.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
1515
const explorer = cosmiconfig('elmapp');
1616
const result = explorer.searchSync(appDirectory);
1717
const config = result ? result.config : loadElmJson();
18+
const id = x => x;
19+
const configureWebpack =
20+
typeof config.configureWebpack === 'function' ? config.configureWebpack : id;
1821

1922
// WARNING:
2023
// We support config in elm.json only for legacy reasons.
@@ -76,5 +79,6 @@ module.exports = {
7679
elm: require.resolve('elm/bin/elm'),
7780
publicUrl: getPublicUrl(config),
7881
servedPath: getServedPath(config),
79-
proxy: config.proxy
82+
proxy: config.proxy,
83+
configureWebpack
8084
};

scripts/build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ function build(previousFileSizes) {
9494
console.log(`Creating an optimized ${process.env.NODE_ENV} build...`);
9595
}
9696

97-
const compiler = webpack(config);
97+
const compiler = webpack(
98+
paths.configureWebpack(config, process.env.NODE_ENV)
99+
);
98100
return new Promise((resolve, reject) => {
99101
compiler.run((err, stats) => {
100102
if (err) {

scripts/eject.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ function performEject(pkg) {
8282
// Update or create new package.json
8383
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
8484

85-
console.log('\nPlease wait for npm to install all required dependencies...');
85+
console.log();
86+
console.log('Please wait for npm to install all required dependencies...');
8687

8788
// Install npm packages
8889
spawn.sync('npm', ['install'], { stdio: 'inherit' });
8990

90-
console.log(chalk.green('\nEjected successfully!'));
91+
console.log();
92+
console.log(chalk.green('Ejected successfully!'));
9193
}
9294

9395
// The following dependencies will be removed:

scripts/start.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ choosePort(HOST, DEFAULT_PORT)
160160
const appName = path.basename(path.dirname(paths.elmJson));
161161
const urls = prepareUrls(protocol, HOST, port);
162162
// Create a webpack compiler that is configured with custom messages.
163-
const compiler = createCompiler(webpack, config, appName, urls);
163+
const compiler = createCompiler(
164+
webpack,
165+
paths.configureWebpack(config, process.env.NODE_ENV),
166+
appName,
167+
urls
168+
);
164169
// Load proxy config
165170
const proxyConfig = prepareProxy(paths.proxy, paths.appPublic);
166171
// Serve webpack assets generated by the compiler over a web sever.

0 commit comments

Comments
 (0)