-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/2.4.0' into craft-webpack
- Loading branch information
Showing
78 changed files
with
25,418 additions
and
2,683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// node modules | ||
const { merge } = require('webpack-merge'); | ||
|
||
/** | ||
* return a webpack settings file | ||
* @param name string | ||
* @returns {{}} | ||
*/ | ||
const getWebpackSettings = (name) => { | ||
let settings = {}; | ||
try { | ||
settings = require('./webpack-settings/' + name + '.settings.js'); | ||
} catch (e) { | ||
// that's okay | ||
} | ||
|
||
return settings; | ||
}; | ||
|
||
/** | ||
* return a webpack settings file combined with the 'app' settings | ||
* @param name string | ||
* @returns {{}} | ||
*/ | ||
const getCombinedWebpackSettings = (name) => ({ | ||
...getWebpackSettings('app'), | ||
...getWebpackSettings(name), | ||
}); | ||
|
||
/** | ||
* return a legacy webpack config file | ||
* @param name | ||
* @returns {{}} | ||
*/ | ||
const getLegacyWebpackConfig = (name) => require('./webpack-configs/' + name + '.config.js')('legacy', getCombinedWebpackSettings(name)); | ||
|
||
/** | ||
* return a modern webpack config file | ||
* @param name | ||
* @returns {{}} | ||
*/ | ||
const getModernWebpackConfig = (name) => require('./webpack-configs/' + name + '.config.js')('modern', getCombinedWebpackSettings(name)); | ||
|
||
/** | ||
* return an array of webpack configs using the function provided in getWebpackConfig | ||
* @param names string[] | ||
* @param getWebpackConfig function | ||
* @returns {{}} | ||
*/ | ||
const webpackConfigs = (names, getWebpackConfig) => { | ||
let config = {}; | ||
names.forEach((name) => config = merge(config, getWebpackConfig(name))); | ||
|
||
return config; | ||
}; | ||
|
||
/** | ||
* return an array of build webpack configs | ||
* @param names string | ||
* @returns {{}} | ||
*/ | ||
const buildWebpackConfigs = (...names) => webpackConfigs(names, getModernWebpackConfig); | ||
|
||
/** | ||
* return an array of legacy webpack configs | ||
* @param names string | ||
* @returns {{}} | ||
*/ | ||
const legacyWebpackConfigs = (...names) => webpackConfigs(names, getLegacyWebpackConfig); | ||
|
||
/** | ||
* return an array of modern webpack configs | ||
* @param names string | ||
* @returns {{}} | ||
*/ | ||
const modernWebpackConfigs = (...names) => webpackConfigs(names, getModernWebpackConfig); | ||
|
||
// module exports | ||
module.exports = { | ||
getWebpackSettings, | ||
getLegacyWebpackConfig, | ||
getModernWebpackConfig, | ||
buildWebpackConfigs, | ||
legacyWebpackConfigs, | ||
modernWebpackConfigs, | ||
}; |
Oops, something went wrong.