admin管理员组文章数量:1399490
I'm in a situation where I want to create "dist" files along a dynamic path but in a specific child directory, which is a sibling to the source directory.
My project structure ideally looks like this:
- files/
- directory1/
- src/
- index.js
- dist/
- index-dist.js
- directory2/
- src/
- index.js
- dist/
- index-dist.js
What I have so far in my Webpack config:
const path = require( 'path' );
const glob = require('glob');
module.exports = ( env ) => {
return {
entry: Object.fromEntries(glob.sync(path.resolve(__dirname, 'files/**/src/index.js')).map((v) => [ v.split('files/')[1], v, ] )),
resolve: {
extensions: [
'.js',
],
},
output: {
path: path.resolve( __dirname, 'files' ),
filename: '[name]-dist.js',
},
}
};
However, this is producing:
- files/
- directory1/
- src/
- index.js <- this is my entry point
- index.js-dist.js <- this is the output
- directory2/
- src/
- index.js <- this is my entry point
- index.js-dist.js <- this is the output
I saw there was something with [path]
that could theoretically be used, but it just created a folder called "[path]" when I tried that.
本文标签: javascriptCreating files in a sibling directoryStack Overflow
版权声明:本文标题:javascript - Creating files in a sibling directory - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744184635a2594232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论