-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mini-runner webpack 配置中,多余参数,导致webpack loader校验参数报错 #5733
Comments
CC @luckyadam |
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
把你的配置贴出来吧 |
const path = require("path");
const { getPKGENV } = require("@pinweb/configurator");
const pkg = require("../package.json");
const resolve = dir => path.resolve(__dirname, dir);
const sassImporter = function(url) {
if (url[0] === "~" && url[1] !== "/") {
return {
file: path.resolve(__dirname, "../../../../", "node_modules", url.substr(1)),
};
}
const reg = /^@\/(.*)/;
return {
file: reg.test(url) ? path.resolve(__dirname, "..", "src/", url.match(reg)[1]) : url,
};
};
module.exports = function(merge) {
const pkgConfig = getPKGENV(pkg.name, process.env.mode);
const raw = pkgConfig.constant;
const ENV = {
NODE_ENV: process.argv.includes("--watch") ? "development" : "production",
...pkgConfig.immutable.ENV,
};
for (const k in ENV) {
process.env[k] = ENV[k];
}
const config = {
projectName: pkg.name,
date: "2019-8-27",
designWidth: 750,
deviceRatio: {
"640": 2.34 / 2,
"750": 1,
"828": 1.81 / 2,
},
sourceRoot: "src",
outputRoot: "dist",
plugins: [],
alias: {
"@": resolve("../src"),
},
framework: "react",
defineConstants: {},
mini: {
webpackChain(config) {
config.plugin("miniCssExtractPlugin").tap(args => {
delete args[0].FRAMEWORK;
delete args[0].TARO_ENV;
return args;
});
config.output.delete("FRAMEWORK");
config.output.delete("TARO_ENV");
config.module
.rule("sass")
.oneOf("1")
.use("1")
.tap(options => {
delete options.FRAMEWORK;
delete options.TARO_ENV;
return options;
});
config.module
.rule("sass")
.oneOf("0")
.use("1")
.tap(options => {
delete options.FRAMEWORK;
delete options.TARO_ENV;
return options;
});
},
sassLoaderOption: {
importer: sassImporter,
},
postcss: {
autoprefixer: {
enable: true,
},
pxtransform: {
enable: true,
config: {},
},
url: {
enable: true,
config: {
limit: 1024, // 设定转换尺寸上限
},
},
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: "module", // 转换模式,取值为 global/module
generateScopedName: "[name]__[local]___[hash:base64:5]",
},
},
},
},
h5: {
publicPath: "/",
staticDirectory: "static",
devServer: {
open: false,
port: process.env.PORT,
proxy: {
"/gateway": {
target: raw.baseApi,
ws: true,
changeOrigin: true,
},
},
},
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: ["last 3 versions", "Android >= 4.1", "ios >= 8"],
},
},
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: "module", // 转换模式,取值为 global/module
generateScopedName: "[name]__[local]___[hash:base64:5]",
},
},
},
},
};
return merge({}, config, {
defineConstants: {
"process.env": Object.keys(raw).reduce((env, key) => {
env[key] = JSON.stringify(raw[key]);
return env;
}, {}),
},
});
}; |
现在用webpack chain 手动删除了参数 |
找到原因 pr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
当前是
monorepo
,webpack 跟loader 版本会跟taro 的库依赖不是一致看源码是一些默认配置被合并了,导致webpack 报错
The text was updated successfully, but these errors were encountered: