Я пытался использовать Tailwind CSS в моем проекте Angular 9. Я смогу заставить его работать нормально, если буду следовать этому руководству: https://dev.to/seankerwin/angular-8-tailwind-css-guide-3m45
Проблема возникает, когда я пытаюсь использовать MiniCssExtractPlugin для разделения моего CSS в другой файл. Я получаю следующую ошибку веб-пакета:
ERROR in ./src/styles/styles.scss
Module build failed (from ./node_modules/@angular-builders/custom-webpack/node_modules/@angular-devkit/build-angular/node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
Error: Didn't get a result from child compiler
at F:\Workspace\portfolio-y2k20\node_modules\mini-css-extract-plugin\dist\loader.js:159:23
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:343:11
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:31:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:678:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compilation.js:1423:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compilation.js:1414:32
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compilation.js:1409:36
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:4:1)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\NormalModule.js:316:20
at F:\Workspace\portfolio-y2k20\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at F:\Workspace\portfolio-y2k20\node_modules\loader-runner\lib\LoaderRunner.js:182:20
at context.callback (F:\Workspace\portfolio-y2k20\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at F:\Workspace\portfolio-y2k20\node_modules\mini-css-extract-plugin\dist\loader.js:159:14
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:343:11
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:31:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:678:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compilation.js:1423:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (F:\Workspace\portfolio-y2k20\node_modules\tapable\lib\Hook.js:154:20)
at F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compilation.js:1414:32
ERROR in Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: Cannot read property 'replace' of undefined
at normalizeBackSlashDirection (F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\RequestShortener.js:16:17)
at new RequestShortener (F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\RequestShortener.js:26:15)
at new Compiler (F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:195:27)
at Compiler.createChildCompiler (F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compiler.js:558:25)
at Compilation.createChildCompiler (F:\Workspace\portfolio-y2k20\node_modules\webpack\lib\Compilation.js:2243:24)
at Object.pitch (F:\Workspace\portfolio-y2k20\node_modules\mini-css-extract-plugin\dist\loader.js:89:43)
My webpack.config.js
:
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { importLoaders: 2 } },
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
syntax: 'postcss-scss',
plugins: () => [
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
],
sourceMap: true,
},
},
'sass-loader',
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
chunkFilename: '[id].[contenthash].css',
}),
],
};
My package.json
:
{
"name": "portfolio-y2k20",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng s -o",
"start:prod": "ng s -o -c=production",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.1.0",
"@angular/cdk": "^9.1.0",
"@angular/common": "~9.1.0",
"@angular/compiler": "~9.1.0",
"@angular/core": "~9.1.0",
"@angular/forms": "~9.1.0",
"@angular/platform-browser": "~9.1.0",
"@angular/platform-browser-dynamic": "~9.1.0",
"@angular/router": "~9.1.0",
"@fortawesome/angular-fontawesome": "^0.6.0",
"@fortawesome/fontawesome-svg-core": "^1.2.27",
"@fortawesome/free-brands-svg-icons": "^5.13.0",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@glidejs/glide": "^3.4.1",
"rxjs": "~6.5.4",
"tailwindcss": "^1.2.0",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^9.0.0",
"@angular-devkit/build-angular": "~0.901.0",
"@angular/cli": "~9.1.0",
"@angular/compiler-cli": "~9.1.0",
"@angular/language-service": "~9.1.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"angular-cli-ghpages": "^0.6.2",
"autoprefixer": "^9.7.6",
"codelyzer": "^5.1.2",
"css-loader": "^3.5.3",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"mini-css-extract-plugin": "^0.9.0",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-scss": "^2.0.0",
"prettier": "^2.0.5",
"protractor": "~5.4.3",
"sass-loader": "^8.0.2",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "~3.7.5"
}
}
My angular.json
:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"portfolio-y2k20": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "ag",
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./webpack.config.js"
},
"outputPath": "dist/portfolio-y2k20",
"baseHref": "/portfolio-y2k20/",
"deployUrl": "/portfolio-y2k20/",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"extractCss": true,
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/styles.scss",
"node_modules/@glidejs/glide/dist/css/glide.core.min.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"customWebpackConfig": {
"path": "./webpack.config.js"
},
"browserTarget": "portfolio-y2k20:build"
},
"configurations": {
"production": {
"browserTarget": "portfolio-y2k20:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "portfolio-y2k20:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/styles.scss",
"node_modules/@glidejs/glide/dist/css/glide.core.min.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": ["**/node_modules/**"]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "portfolio-y2k20:serve"
},
"configurations": {
"production": {
"devServerTarget": "portfolio-y2k20:serve:production"
}
}
},
"deploy": {
"builder": "angular-cli-ghpages:deploy",
"options": {}
}
}
}
},
"defaultProject": "portfolio-y2k20"
}
Вот еще мой tailwind.config.js
, если важно:
module.exports = {
theme: {
extend: {
screens: {
xxl: '1440px',
fullHD: '1920px',
'4k': '2560px',
},
},
textColor: {
primary: 'var(--color-text-primary)',
secondary: 'var(--color-text-secondary)',
'app-primary': 'var(--color-primary)',
'app-secondary': 'var(--color-secondary)',
navbar: 'var(--color-text-navbar)',
},
backgroundColor: {
primary: 'var(--color-primary)',
secondary: 'var(--color-secondary)',
'app-primary': 'var(--color-bg-primary)',
'app-secondary': 'var(--color-bg-secondary)',
navbar: 'var(--color-bg-navbar)',
},
},
};
Что я здесь не так делаю? Я подозреваю, что проблема в том, как я определяю свои загрузчики, но порядок и предоставленные параметры кажутся правильными. Пожалуйста, помогите мне.