UNPKG

ttk-app-core

Version:

@ttk/recat enterprise develop framework

94 lines (93 loc) 5.2 kB
const path = require("path") // 联邦模块配置 const { moduleFederationPlugins } = require("./config/moduleFederation") // 开发服务配置 const { devServer } = require("./config/devServer") // 项目目录下(package.json所在目录,下同)新建 fx.webpack.config.js module.exports = { fxVue: false, // 是否使用Vue fxReact: true, // 是否使用React fxMoment: true, // 是否使用moment包,true时,配置IgnorePlugin,忽略moment的locale文件引入 fxPreProcessors: { less: true, // 是否使用less scss: true, // 是否使用scss sass: true, // 是否使用sass postcss: false, // 是否使用postcss styl: false, // 是否使用styl stylus: false, // 是否使用stylus cssOption: {}, // css配置,参考 https://www.webpackjs.com/loaders/css-loader/#选项 lessOption: { lessOptions: { "modifyVars": { "theme": `true; @import "${path.resolve(__dirname, './src/assets/varible.less')}"` // theme切换只需要替换css变量,不需要多次引入index. }, "javascriptEnabled": true } }, // less配置,参考 https://www.webpackjs.com/loaders/less-loader/#示例 sassOption: {}, // sass/scss配置,参考 https://www.webpackjs.com/loaders/sass-loader/#示例 postcssOption: {}, // postcss配置,参考 https://www.webpackjs.com/loaders/postcss-loader/#options stylusOption: {}, // stylus/styl配置,参考 https://github.com/shama/stylus-loader sassResourcesPath: [] // sass/scss全局变量文件,配置相对路径,例如sassResourcesPath: ['src/assets/scss/global.scss'] }, fxPublicPath: '/', // output.publicPath fxEntry: './src/index.js', // 单个应用入口, fxOutputPath: 'dist', // 输出目录名称 fxAssetsPath: 'static', // 输出静态文件目录 fxAppPublic: 'static',// 要拷贝的源文件目录名称 fxCopyList: [ { from: 'public/**/*', transformPath(targetPath, absolutePath) { /** * 删掉public/,拷贝到输出目录下(即fxOutputPath配置的目录下,一般为dist), * 为了保持vendor/、version.txt等路径不变 */ return targetPath.substring(7); }, globOptions: { // 忽略index.html模板 ignore: ['**/public/index.html'], }, }, ], // CopyWebpackPlugin配置 fxHtml: { title: 'TTK框架', // 生成html文件的标题,在模板中配置<title><%= htmlWebpackPlugin.options.title %></title> template: './public/index.html', // html模板文件名,请放在项目目录下 filename: 'index.html', // 输出的html的文件名称,将输出到fxOutputPath配置目录下 }, fxAlias: { '@': path.resolve(__dirname, 'src'), // 创建import或require的别名,来确保模块引入变得更简单,配置相对路径,例如 'assets_img_common': 'src/assets/img/common'。 // 以下为兼容json项目配置,hook项目可删除 'edf-utils': path.resolve(__dirname, 'src/utils/index.js'), 'webapi': path.resolve(__dirname, 'src/api/index.js'), 'edf-consts': path.resolve(__dirname, 'src/constant/consts.js'), 'edf-constant': path.resolve(__dirname, 'src/constant/index.js'), 'edf-meta-engine': '@ttk/meta-engine', 'edf-component': path.resolve(__dirname, 'src/components/index.js'), '../../../vendor': path.resolve(__dirname, 'public/vendor'), '../../../../vendor': path.resolve(__dirname, 'public/vendor'), '../../../component/decorator': '@/components/decorator', '../../../modules/loadGlobalModules': path.resolve(__dirname, 'src/jsonApps/departcated.js'), 'os': 'os-browserify/browser', // 确有需要的,安装'os-browserify'依赖,该值改为'os-browserify/browser' 'path': false, // 确有需要的,安装'path-browserify'依赖,该值改为'path-browserify' 'util': false, // 确有需要的,安装'path-browserify'依赖,该值改为'path-browserify' 'constants': false, // 确有需要的,安装'path-browserify'依赖,该值改为'path-browserify' 'zlib': false, // 确有需要的,安装'browserify-zlib'依赖,该值改为'browserify-zlib' }, fxOptimizationMinimize: true, // build打包模式下是否启用TerserPlugin压缩代码插件,true:启用;false: 关闭 fxEcmaVersion: 5, // build打包模式下启用TerserPlugin时,选择ecma版本,传5, 2015, 2016等等 fxBundleAnalyzer: false, // 是否启用BundleAnalyzer插件,分析依赖,true:启用;false: 关闭 fxDevServer: devServer, fxWebpack: { // 以下配置已有默认值,一般无需配置,若有需要,请按webpack配置要求进行配置 module: { rules: [], }, optimization: {}, performance: {}, externals: {}, plugins: [ ...moduleFederationPlugins, ] } }