Skip to content

Commit

Permalink
feat: allow userConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
HomyeeKing committed Jan 20, 2025
1 parent 67a23ef commit 56bb1ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ice/src/service/serverCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export function createServerCompiler(options: Options) {
const externals = task.config?.externals || {};
const sourceMap = task.config?.sourceMap;
const dev = command === 'start';

// Filter empty alias.
const { ignores, alias } = filterAlias(task.config?.alias || {});

Expand Down Expand Up @@ -273,6 +272,7 @@ export function createServerCompiler(options: Options) {
new ModifyRequirePlugin(),
].filter(Boolean),
rootDir,
userServerConfig: server,
});
esbuildResult = (await webpackServerCompiler.build())?.compilation;
}(buildOptions);
Expand Down
9 changes: 7 additions & 2 deletions packages/ice/src/service/webpackServerCompiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class WebpackServerCompiler {
}

private createWebpackConfig(options: any): webpack.Configuration {
const { userServerConfig } = options;
const { webpackConfig = {} } = userServerConfig;
const cssRules = [
['css'],
[
Expand Down Expand Up @@ -112,7 +114,7 @@ export class WebpackServerCompiler {
const cssChunkFilename = undefined;

for (const key of Object.keys(options.alias)) {
if ((options.alias[key]).startsWith('./')) {
if (options.alias[key].startsWith('./')) {
options.alias[key] = path.resolve(options.rootDir, options.alias[key]);
}
}
Expand Down Expand Up @@ -156,6 +158,7 @@ export class WebpackServerCompiler {
extractComments: false,
}),
],
...webpackConfig.optimization,
},
resolve: {
alias: options.alias,
Expand Down Expand Up @@ -190,7 +193,8 @@ export class WebpackServerCompiler {
// available options: https://github.com/evanw/esbuild/blob/88821b7e7d46737f633120f91c65f662eace0bcf/lib/shared/types.ts#L158-L172
options: {
target: options.target,
format: options.format,
// make sure tree shaking is worked
format: 'esm',
loader: 'tsx',
jsx: options.jsx,
jsxImportSource: '@ice/runtime/react',
Expand Down Expand Up @@ -222,6 +226,7 @@ export class WebpackServerCompiler {
// If the warning is triggered, it seen to be unactionable for the user,
ignoreOrder: true,
}),
...webpackConfig.plugins,
],
stats: {
errorDetails: true,
Expand Down

0 comments on commit 56bb1ee

Please sign in to comment.