[英]How do I copy an entire directory into dist/ using custom webpack with angular-builders?
I'm using Angular builders to add some additional files and folders in the dist/
directory generated.我正在使用 Angular 构建器在生成的
dist/
目录中添加一些额外的文件和文件夹。 In this case I want to have the directories src/assert/puppies
and src/assert/kittens
copied into a folder called animals/
.在这种情况下,我希望将目录
src/assert/puppies
和src/assert/kittens
复制到名为animals/
的文件夹中。
In other words, I want this换句话说,我想要这个
src/
|--- assets/
|----puppies/
|--- *.jpg
|--- ....
|----kittens/
|--- *.jpg
|--- ....
to become this成为这个
dist/
| main.js
| vendor.js
| ...
|--- animals/
|--- images...
angular.json angular.json
This is the relevant portion of my angular.json file:这是我的 angular.json 文件的相关部分:
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json",
{
"input": "node_modules/jquery/dist",
"glob": "jquery.js",
"output": "./vendor"
}
],
"styles": ["src/styles.scss"],
"scripts": [],
"customWebpackConfig": {
"path": "./custom-webpack.config.js"
}
},
This is my custom-webpack.config.js
.这是我的
custom-webpack.config.js
。 I already have this content in there because I want these scripts to be compiled and copied over.我已经在那里有了这些内容,因为我希望编译和复制这些脚本。
module.exports = {
entry: {
"special-scripts/login":
"src/custom/login/login.ts",
"special-scripts/logout":
"src/custom/logout/logout.ts"
}
};
What do I add to custom-webpack.config.js
to get it to copy over those asset folders into dist/
in the way I described above?我要向
custom-webpack.config.js
添加什么以使其以上述方式将这些资产文件夹复制到dist/
中?
You can use the CopyWebpackPlugin .您可以使用CopyWebpackPlugin 。
Import it into your custom-webpack.config.js:将其导入您的 custom-webpack.config.js:
const CopyPlugin = require('copy-webpack-plugin');
Then add it to your plugins:然后将其添加到您的插件中:
plugins: [
new CopyPlugin([
{ from: './src/assets/*', to: 'dist/animals/' },
]),
...
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.