diff --git a/packages/fes-builder-webpack/src/plugins/common/webpackConfig/css.js b/packages/fes-builder-webpack/src/plugins/common/webpackConfig/css.js index aeecc3e4..5abb1ad7 100644 --- a/packages/fes-builder-webpack/src/plugins/common/webpackConfig/css.js +++ b/packages/fes-builder-webpack/src/plugins/common/webpackConfig/css.js @@ -101,6 +101,9 @@ export default function createCssWebpackConfig({ isDev, config, webpackConfig, b config.extraCSS?.plugin ?? {}, ), ]); + } + + if (!isDev) { webpackConfig.optimization.minimizer('css').use(require.resolve('css-minimizer-webpack-plugin'), [{}]); } diff --git a/packages/fes-builder-webpack/types.d.ts b/packages/fes-builder-webpack/types.d.ts index 802a385e..88786413 100644 --- a/packages/fes-builder-webpack/types.d.ts +++ b/packages/fes-builder-webpack/types.d.ts @@ -1,30 +1,30 @@ -import Config from 'webpack-5-chain' +import Config from 'webpack-5-chain'; import webpack from 'webpack'; -import HtmlWebpackPlugin from 'html-webpack-plugin' -import { LoaderOptions, PluginOptions } from 'mini-css-extract-plugin' +import HtmlWebpackPlugin from 'html-webpack-plugin'; +import { LoaderOptions, PluginOptions } from 'mini-css-extract-plugin'; interface CopyFileType { from: string; to: string; } -declare module "@fesjs/fes" { +declare module '@fesjs/fes' { interface PluginBuildConfig { analyze?: { analyzerMode?: 'server' | 'static' | 'disabled'; analyzerHost?: string; analyzerPort?: number | 'auto'; openAnalyzer?: boolean; - generateStatsFile?: boolean; + generateStatsFile?: boolean; statsFilename?: string; logLevel?: 'info' | 'warn' | 'error' | 'silent'; - defaultSizes?: 'stat' | 'parsed' | 'gzip' + defaultSizes?: 'stat' | 'parsed' | 'gzip'; }; - chainWebpack?: (memo: Config, args: {env: string, webpack: typeof webpack}) => void; + chainWebpack?: (memo: Config, args: { env: string; webpack: typeof webpack }) => void; copy?: CopyFileType | CopyFileType[]; cssLoader?: { url?: boolean | ((url: string, resourcePath: string) => boolean); - import?: boolean | ({ filter: (url: string, media: string, resourcePath: string) => boolean }); + import?: boolean | { filter: (url: string, media: string, resourcePath: string) => boolean }; modules?: boolean | string | object; sourceMap?: boolean; importLoaders?: number; @@ -51,13 +51,13 @@ declare module "@fesjs/fes" { html?: HtmlWebpackPlugin.Options; lessLoader?: Record; nodeModulesTransform?: { - exclude: string[] + exclude: string[]; }; postcssLoader?: Record; vueLoader?: object; extraCSS?: { - loader?: LoaderOptions, - plugin?: PluginOptions + loader?: LoaderOptions; + plugin?: PluginOptions; }; } } diff --git a/packages/fes-template-vite/.fes.js b/packages/fes-template-vite/.fes.js index e538bd27..546447c1 100644 --- a/packages/fes-template-vite/.fes.js +++ b/packages/fes-template-vite/.fes.js @@ -1,7 +1,7 @@ import { defineBuildConfig } from '@fesjs/fes'; export default defineBuildConfig({ - builder: 'vite', + builder: 'webpack', define: { __DEV__: false, }, diff --git a/packages/fes-template-vite/.fes.local.js b/packages/fes-template-vite/.fes.local.js index c79e932e..ad88c6cf 100644 --- a/packages/fes-template-vite/.fes.local.js +++ b/packages/fes-template-vite/.fes.local.js @@ -1,7 +1,7 @@ -import { defineBuildConfig } from "@fesjs/fes"; +import { defineBuildConfig } from '@fesjs/fes'; -export default { +export default defineBuildConfig({ // define: { // __DEV__: true // }, -} \ No newline at end of file +}); diff --git a/packages/fes-template/.fes.js b/packages/fes-template/.fes.js index 75b7ddd4..3c37a21f 100644 --- a/packages/fes-template/.fes.js +++ b/packages/fes-template/.fes.js @@ -1,7 +1,6 @@ import { defineBuildConfig } from '@fesjs/fes'; export default defineBuildConfig({ - swc: false, targets: { chrome: '78', }, @@ -89,5 +88,4 @@ export default defineBuildConfig({ monacoEditor: { languages: ['javascript', 'typescript', 'html', 'json'], }, - presets: [require.resolve('../fes-builder-webpack/lib')], }); diff --git a/packages/fes-template/.fes.local.js b/packages/fes-template/.fes.local.js index b2d4c3ea..ad88c6cf 100644 --- a/packages/fes-template/.fes.local.js +++ b/packages/fes-template/.fes.local.js @@ -1,5 +1,7 @@ -export default { +import { defineBuildConfig } from '@fesjs/fes'; + +export default defineBuildConfig({ // define: { // __DEV__: true // }, -}; +}); diff --git a/packages/fes-template/.fes.prod.js b/packages/fes-template/.fes.prod.js index c82cedcf..25885db2 100644 --- a/packages/fes-template/.fes.prod.js +++ b/packages/fes-template/.fes.prod.js @@ -1,7 +1,7 @@ -// .fes.js 只负责管理编译时配置,只能使用plain Object import path from 'path'; +import { defineBuildConfig } from '@fesjs/fes'; -export default { +export default defineBuildConfig({ // publicPath: 'https://gw.alipayobjects.com/', // 配置 mini-css-extract-plugin extraCSS: { @@ -9,4 +9,4 @@ export default { publicPath: (resourcePath, context) => `${path.relative(path.dirname(resourcePath), context)}/`, }, }, -}; +}); diff --git a/packages/fes-template/package.json b/packages/fes-template/package.json index 6d44de8c..52743822 100644 --- a/packages/fes-template/package.json +++ b/packages/fes-template/package.json @@ -45,6 +45,7 @@ }, "dependencies": { "@fesjs/fes": "workspace:*", + "@fesjs/builder-webpack": "workspace:*", "@fesjs/plugin-login": "workspace:*", "@fesjs/plugin-access": "workspace:*", "@fesjs/plugin-enums": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75a5e1e3..086ef956 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -750,6 +750,9 @@ importers: packages/fes-template: dependencies: + '@fesjs/builder-webpack': + specifier: workspace:* + version: link:../fes-builder-webpack '@fesjs/fes': specifier: workspace:* version: link:../fes @@ -4541,6 +4544,7 @@ packages: /@vuepress/shared@2.0.0-beta.50-pre.1: resolution: {integrity: sha512-Gk6ikIV2V8LMokc+H/juH+kBOigo38Woup42Q2pmmWqmlwdLqbUcCYZSt/z+opeOUAqC9s3CZnKR8xCw+qo8BQ==} + deprecated: deprecated dependencies: '@vue/shared': 3.2.47 dev: false