admin管理员组文章数量:1279246
I have a public folder that looks as follows:
After building the project with
"prod": "npm run mlbuild | npm run build"
the dist folder looks as following:
But I am missing config.json
, favicon.ico
and keycloak.json
.
How to take these files into dist
folder during the build
?
I tried:
{
test: /\.(json)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}]
}
But I think, I have to mention the folder.
I have a public folder that looks as follows:
After building the project with
"prod": "npm run mlbuild | npm run build"
the dist folder looks as following:
But I am missing config.json
, favicon.ico
and keycloak.json
.
How to take these files into dist
folder during the build
?
I tried:
{
test: /\.(json)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}]
}
But I think, I have to mention the folder.
Share Improve this question edited May 19, 2018 at 23:14 Eby Jacob 1,4581 gold badge12 silver badges29 bronze badges asked May 19, 2018 at 21:01 softshippersoftshipper 34.1k61 gold badges227 silver badges451 bronze badges 1- Possible duplicate of How to copy static files to build directory with Webpack? – Andrea Carraro Commented May 19, 2018 at 21:54
1 Answer
Reset to default 11You can just setup the plugin copy-webpack-plugin to copy those files, adding this to your webpack.config.js:
plugins: [
new CopyWebpackPlugin([{ from: 'public' }])
]
and the following require: const CopyWebpackPlugin = require('copy-webpack-plugin')
Another solution, if you don't want to do it using webpack, is to use a package to copy those files to the dist folder after the build, adding the following script:
"postprod": "cpx \"public/*\" dist"
and add the package cpx
to your list of devDependencies, running npm install cpx --save-dev
.
Because you added the post
prefix to postprod
, everytime you run the prod
script, npm will automatically run postprod
after it, and therefore, will copy all files inside the public folder to the dist folder. You can read more about npm scripts here
本文标签: javascriptHow to copy files from public into distStack Overflow
版权声明:本文标题:javascript - How to copy files from public into dist? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741270501a2369195.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论