// bash npm run eject
导出scripts后npm install
从新下载依赖react
// path.js // 37行pathname改成相对路径 function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : './'); return ensureSlash(servedUrl, true); }
// 73行appBuild改成以下自定义路径 appBuild: path.resolve(__dirname, '../../dist/panorama'),
最终打包路径为 项目外部dist下,包名为panoramawebpack
// bash npm install less less-loader -D
webpack.config.js中配置web
// style files regexes // 添加下面两行,同上方sass配置 const lessRegex = /\.less$/; const lessModuleRegex = /\.module\.less$/;
rules中添加npm
// 跟上方sass配置相同,把sass换成less便可 { test: lessRegex, exclude: lessModuleRegex, use: getStyleLoaders( { importLoaders: 2, sourceMap: isEnvProduction && shouldUseSourceMap, }, 'less-loader' ), sideEffects: true, }, { test: lessModuleRegex, use: getStyleLoaders( { importLoaders: 2, sourceMap: isEnvProduction && shouldUseSourceMap, modules: true, getLocalIdent: getCSSModuleLocalIdent, }, 'less-loader' ), },
alias中添加sass
// 引用时直接@/assets/... '@': paths.appSrc,