Answer the question
In order to leave comments, you need to log in
How to build an Angular library with a separate Webpack.config?
I created the Angular library inside the workspace itself.
How to tell angular that it needs to be built not through angular.json but through its own webpack.config?
Now the angular.json configurator is like this:
"test-lib": {
"projectType": "library",
"root": "projects/test-lib",
"sourceRoot": "projects/test-lib/src",
"prefix": "tl",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/test-lib/tsconfig.lib.json",
"project": "projects/test-lib/ng-package.json"
}
}
}
var path = require("path");
var webpack = require("webpack");
module.exports = {
module: {
rules: [
{
test: /\.css$/,
include: path.join(__dirname, './projects/src/lib'),
use: [
'style-loader',
{
loader: 'typings-for-css-modules-loader',
options: {
modules: true,
namedExport: true
}
}
]
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
"style-loader",
{
loader: "typings-for-css-modules-loader",
options: {
modules: true,
namedExport: true,
silent: true,
localIdentName: production ? "r_[hash:base64:5]" : "[local]___[hash:base64:5]"
}
},
{ loader: "sass-loader" }
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'STABLE_FEATURE': JSON.stringify(true),
'EXPERIMENTAL_FEATURE': JSON.stringify(false)
})
]
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question