alibaba / ice

🚀 ice.js: The Progressive App Framework Based On React(基于 React 的渐进式应用框架)
https://ice.work
MIT License
17.84k stars 2.09k forks source link

ice2.0用webpack模式打包的时候出错 #5438

Closed wxadrtyu closed 2 years ago

wxadrtyu commented 2 years ago

ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.

` // build.config.js import { viteCommonjs } from '@originjs/vite-plugin-commonjs';

const env = process.env.NODE_ENV;

export default { vitePlugins: env === 'development' ? [viteCommonjs()] : [], hash: true, // minify: 'terser', // publicPath: './', vite: env === 'development', sourceMap: 'cheap-module-source-map', outputDir: 'build', plugins: [ 'build-plugin-antd', 'build-plugin-jsx-plus', [ 'build-plugin-moment-locales', { locales: ['zh-cn'], }, ], ['build-plugin-keep-alive'], ], babelPresets: [], proxy: { '/api': { enable: true, target: 'https://oms-kct-st.api.muftc.com/', changeOrigin: true, secure: false, pathRewrite: { '/api': '/' }, }, }, lessLoaderOptions: { lessOptions: { javascriptEnabled: true, modifyVars: { '@primary-color': '#1DA57A' }, }, }, }; `

// package.json { "name": "kct-dm-wxapp-omfe", "version": "1.0.0", "description": "智能收运管理系统", "author": "linjiazhen_ito", "keywords": [ "ice-scaffold" ], "scripts": { "start": "icejs start", "start:st1": "icejs start --mode st1", "start:st2": "icejs start --mode st2", "start:st3": "icejs start --mode st3", "start:uat": "icejs start --mode uat", "build": "icejs build --mode st && set NODE_ENV=st && node buildGzip", "build:st": "icejs build --mode st3 && set NODE_ENV=st && node buildGzip", "build:prod": "icejs build --mode prod && set NODE_ENV=prod && node buildGzip", "lint": "npm run eslint && npm run stylelint", "eslint": "eslint --cache --ext .js,.jsx ./", "stylelint": "stylelint ./**/*.scss" }, "dependencies": { "@ant-design/compatible": "1.0.1", "@ant-design/icons": "^4.7.0", "@icemucfc/mucomponents": "^0.6.8", "@mu/madp-utils": "1.8.0-beta.15", "@pansy/react-amap": "^2.12.3", "@pansy/react-amap-ui": "^2.1.6", "array-move": "^3.0.1", "designare-table": "^1.2.8", "dynamic-antd-theme": "0.4.1", "echarts": "^5.2.2", "echarts-for-react": "^3.0.2", "flv.js": "^1.6.2", "hls.js": "^1.1.5", "ice.js": "^2.0.0", "js-md5": "^0.7.3", "lodash": "4.17.15", "moment": "2.24.0", "mud": "^0.1.10", "pdf.js": "^0.1.0", "prop-types": "15.7.2", "qs": "6.9.3", "react": "16.13.1", "react-amap": "^1.2.8", "react-bmapgl": "^0.1.28", "react-dom": "16.13.1", "react-images": "^1.2.0-beta.7", "react-images-viewer": "^1.7.1", "react-player": "^2.10.0", "react-select": "^5.3.0", "react-sortable-hoc": "^1.11.0", "shortid": "^2.2.16" }, "devDependencies": { "@babel/preset-env": "^7.18.9", "@babel/preset-react": "^7.18.6", "@commitlint/cli": "11.0.0", "@icemucfc/spec": "0.0.4", "@originjs/vite-plugin-commonjs": "^1.0.3", "antd": "^4.16.13", "build-plugin-antd": "0.1.0", "build-plugin-fusion": "0.1.7", "build-plugin-jsx-plus": "^0.1.4", "build-plugin-keep-alive": "^1.8.1", "build-plugin-moment-locales": "0.1.0", "colors": "1.4.0", "copy-webpack-plugin": "5.1.1", "eslint": "6.8.0", "eslint-plugin-react-hooks": "^2.4.0", "husky": "^4.3.8", "less-loader": "^5.0.0", "lint-staged": "10.5.1", "node-sass": "4.14.1", "prettier": "^2.6.2", "react-select": "^5.3.0", "shelljs": "^0.8.5", "shortid": "^2.2.16", "stylelint": "13.2.1", "vite": "^2.9.14" }, "lint-staged": { "**/*.{js,jsx}": [ "eslint --fix", "git add" ] }, "husky": { "hooks": { "pre-commit": "lint-staged", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, "ideMode": { "name": "ice-react" }, "iceworks": { "type": "react", "adapter": "adapter-react-v3" }, "engines": { "node": ">=8.0.0" }, "scaffoldConfig": { "builder": "icejs", "name": "scaffold-lite-js", "title": "智能收运管理系统", "categories": [ "基础模板" ], "sort": 3 }, "repository": { "type": "git", "url": "http://gitlab.mucfc.com/odt/odt-fe/ice-meterials/tree/master/scaffolds/ScaffoldLiteJs" }, "title": "kct-dm-wxapp-omfe" }

ClarkXia commented 2 years ago

less-loader 的 API 对不上,可以看下详细的错误日志,定位下具体是哪个地方的 less 配置

wxadrtyu commented 2 years ago

@ClarkXia 我并没有配置less其实,我整个项目都是用的sass,很奇怪

ClarkXia commented 2 years ago

那为什么配置 lessLoaderOptions ?

ClarkXia commented 2 years ago

先移除 build.json 中的 lessLoaderOptions,并确保依赖最新