是的,Angular使用webpack作为默认的构建工具。webpack的配置文件在项目根目录下的angular.json
文件中。
下面是一个简单的示例,展示如何使用webpack进行配置:
打开angular.json
文件,找到build
和serve
属性,它们对应着构建和开发服务器的配置。
在build
属性中,找到options
对象,并在其中添加webpackConfig
属性,指定webpack配置文件的路径。例如:
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/my-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": [],
"webpackConfig": "webpack.config.js" // 添加这行代码
},
...
},
webpack.config.js
文件,并在其中编写webpack的配置。例如:module.exports = {
// 配置项
};
通过以上步骤,你可以使用自定义的webpack配置来构建和打包Angular项目。