我想实现这样的目标:
npm run build --path custom
为了设置将在 webpack.config.js 中使用的不同 output.path
这样的事情存在吗?
我想实现这样的目标:
npm run build --path custom
为了设置将在 webpack.config.js 中使用的不同 output.path
这样的事情存在吗?
我设法实现了类似于我的目标的东西,比如使用这样的配置字段:
"name": "foo",
"config": {
"dist": "bar"
},
"scripts": {
"build": "webpack --watch",
"custom": "node test.js"
}
...
我设法修改了dist ("bar")
with 的值:
npm config set foo:dist apple
我可以通过以下方式访问值dist
:
process.env.npm_package_config_dist
可能并不理想,但它确实有效。我愿意接受更好的建议。
最终使用的解决方案使用了这个命令:
DIST=[YOUR-DIRECTORY] npm run build
webpack.config
处理类似的值DIST
:
const target = process.env.DIST
? process.env.DIST
: 'dist';
在我们的输出中:
path: path.resolve(__dirname, target)
你可以试试这个:
"name": "npm-help",
"scripts": {
"build": **"sass --watch"**,
}