Skip to content

Commit 92b5308

Browse files
committed
feat: Enable the option to overwrite Webpack config by using 'elmapp.config.js' configuration file
1 parent f456bcb commit 92b5308

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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/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)