admin管理员组文章数量:1322850
I want to create a file named background.js
inside my build
folder. This is the mand I use:
webpack --mode production ./src/background -o ./build/background.js
But this creates a folder named background.js
inside my build folder. I didn't find any other flag on the webpack-cli documentation. So how do I specify an output filename with the Webpack CLI?
I want to create a file named background.js
inside my build
folder. This is the mand I use:
webpack --mode production ./src/background -o ./build/background.js
But this creates a folder named background.js
inside my build folder. I didn't find any other flag on the webpack-cli documentation. So how do I specify an output filename with the Webpack CLI?
2 Answers
Reset to default 7You could try --output-filename
:
https://v4.webpack.js/api/cli/#output-options
webpack --mode production --entry src/background/index.js --output-filename background.js -o ./build
Per the docs, here's a list of core flags from v4 that are supported in v5: https://github./webpack/webpack-cli/tree/next/packages/webpack-cli#webpack-5
in the webpack.config.js folder add this on the top,
const path = require("path");
then your Module exports will be:
module.exports = {
module: {
rules: [
// your rules, eg, babel loder.
],
},
// the main solution
entry: "./src/index.js", // your entry file that you want it to be bundled for production
output: { // the output file path,
path: path.resolve(__dirname, "build"),// build is your folder name.
filename: "background.js", // your specific filename to be built in the build folder.
}, };
and finally your package.json build script will be
"build": "webpack --mode production",
本文标签: javascriptHow to specify an output filename with the Webpack CLIStack Overflow
版权声明:本文标题:javascript - How to specify an output filename with the Webpack CLI? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742112241a2421307.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论