feat: platform suffix resolution [wip]

This commit is contained in:
Igor Randjelovic
2020-11-30 19:02:30 +01:00
parent ca78bc5ae8
commit 65b214b845
3 changed files with 182 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import {
getPlatform,
} from '../helpers/project';
import { hasDependency } from '../helpers/dependencies';
import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
export default function (config: Config, env: IWebpackEnv): Config {
const entryPath = getEntryPath();
@ -28,6 +29,10 @@ export default function (config: Config, env: IWebpackEnv): Config {
// set mode
config.mode(mode);
// config.stats({
// logging: 'verbose'
// })
// package.json is generated by the CLI with runtime options
// this ensures it's not included in the bundle, but rather
// resolved at runtime
@ -194,6 +199,22 @@ export default function (config: Config, env: IWebpackEnv): Config {
},
]);
// config.plugin('NormalModuleReplacementPlugin').use(NormalModuleReplacementPlugin, [
// /.*/,
// request => {
// if (new RegExp(`\.${platform}\..+$`).test(request.request)) {
// request.rawRequest = request.rawRequest.replace(`.${platform}.`, '.')
// console.log(request)
// }
// }
// ])
config.plugin('PlatformSuffixPlugin').use(PlatformSuffixPlugin, [
{
platform,
},
]);
// todo: refine defaults
config.plugin('DefinePlugin').use(DefinePlugin, [
{