Related
We have a problem when we do yarn build on our project. Upon investigating it, we found that the mixins that curly braces create an error.
Below is the mixin that we have:
#mixin headings($from: 1, $to: 6) {
#for $i from $from through $to {
h#{ $i } {
#content;
}
}
}
Currently, here is our package.json
{
"name": "sage",
"private": true,
"browserslist": [
"extends #roots/browserslist-config"
],
"engines": {
"node": ">=16.0.0"
},
"type": "module",
"scripts": {
"dev": "bud dev",
"build": "bud build",
"translate": "yarn translate:pot && yarn translate:update",
"translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --include=\"app,resources\"",
"translate:update": "for filename in ./resources/lang/*.po; do msgmerge -U $filename ./resources/lang/sage.pot; done; rm -f ./resources/lang/*.po~",
"translate:compile": "yarn translate:mo && yarn translate:js",
"translate:js": "wp i18n make-json ./resources/lang --pretty-print",
"translate:mo": "wp i18n make-mo ./resources/lang ./resources/lang",
"lint": "yarn lint:js && yarn lint:css",
"lint:js": "eslint resources/scripts",
"lint:css": "stylelint \"resources/**/*.{css,scss,vue}\"",
"test": "yarn lint"
},
"devDependencies": {
"#roots/bud": "^6.8.0",
"#roots/bud-eslint": "^6.8.0",
"#roots/bud-prettier": "^6.8.0",
"#roots/bud-sass": "^6.8.0",
"#roots/bud-stylelint": "^6.8.0",
"#roots/bud-tailwindcss": "6.8.0",
"#roots/eslint-config": "^6.8.0",
"#roots/sage": "6.8.0"
},
"dependencies": {
"alpinejs": "^3.11.1"
}
}
We're not sure what is the missing piece here as we already have all the dependencies we need.
Here is the error we experience
I am currently modifying the configuration file a Vue app (acting here as a host app) to implement the plugin of webpack : ModuleFederationPlugin.
The goal for me is to set up a micro-frontend architecture by getting a component from a remote app called "foo".
Here is the code to reproduce the issue :
config file host app :
const path = require("path");
const helpers = require("./config/helpers");
const { ModuleFederationPlugin } = require("webpack").container;
const config = {
configureWebpack: {
entry: {
polyfill: "#babel/polyfill",
},
stats: {
cached: false,
cachedAssets: false,
chunks: false,
chunkModules: false,
chunkOrigins: false,
modules: false,
},
devServer: {
historyApiFallback: true,
port: 8765,
},
plugins: [
new ModuleFederationPlugin({
name: "vue",
remotes: {
foo: "foo#http://localhost:5173/remoteEntry.js",
},
}),
],
},
pluginOptions: {
"style-resources-loader": {
preProcessor: "scss",
patterns: [],
},
},
};
module.exports = config;
package.json host app :
{
"name": "Test",
"version": "1.0.0",
"description": "Test",
"author": "Test",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"vue": "^2.6.10"
},
"devDependencies": {
"#babel/core": "7.7.2",
"#babel/plugin-transform-runtime": "7.6.2",
"#babel/preset-env": "7.7.1",
"#babel/register": "7.7.0",
"#vue/cli-plugin-babel": "^4.0.5",
"#vue/cli-plugin-eslint": "^4.0.5",
"#vue/cli-service": "^4.0.5",
"#vue/eslint-config-airbnb": "^5.0.0",
"babel-plugin-istanbul": "5.2.0",
"cache-loader": "^4.1.0",
"eventsource-polyfill": "0.9.6",
"image-webpack-loader": "^6.0.0",
"karma-webpack": "4.0.2",
"selenium-server": "3.141.59",
"url-loader": "^2.2.0",
"vue-cli-plugin-style-resources-loader": "^0.1.4",
"vue-loader": "15.7.2",
"vue-style-loader": "4.1.2",
"vue-template-compiler": "2.6.10",
"webpack": "^4.41.2",
"webpack-merge": "4.2.2"
},
"engines": {
"node": ">= 8.0.0",
"npm": ">= 5.0.0"
}
}
yarn version host app : 1.22.19
node version host app : v12.0.0
config file remote app :
import svgr from "vite-plugin-svgr"
import { defineConfig } from "vite"
import react from "#vitejs/plugin-react"
import * as path from "path"
import federation from "#originjs/vite-plugin-federation"
export default defineConfig({
plugins: [
svgr(),
react(),
federation({
name: "foo",
filename: "remoteEntry.js",
exposes: {
"./App": "./src/App.tsx",
},
}),
],
build: {
target: "esnext",
assetsDir: "assets",
},
server: {
host: "0.0.0.0",
port: 5173,
},
})
package.json file of the remote app :
{
"name": "test",
"version": "1.0.0",
"description": "test",
"author": "test",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:prod": "tsc && vite build",
"build:demo": "tsc && vite build --mode demo",
"preview": "vite preview",
"lint:check": "eslint \"./src/**/*.{ts,tsx}\"",
"lint:fix": "eslint --fix \"./src/**/*.{ts,tsx}\"",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write ."
},
"dependencies": {
"#emotion/react": "^11.10.0",
"#emotion/styled": "^11.10.0",
"#mui/icons-material": "^5.10.9",
"#mui/material": "^5.10.0",
"#mui/x-date-pickers": "^5.0.0",
"#originjs/vite-plugin-federation": "^1.1.11",
"axios": "^0.27.2",
"classnames": "^2.3.1",
"dayjs": "^1.11.5",
"i18next": "^21.8.14",
"moment": "^2.29.4",
"npm": "^8.19.2",
"react": "^18.2.0",
"react-charts": "=3.0.0-beta.30",
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.33.1",
"react-i18next": "^11.18.1",
"react-number-format": "^5.0.1",
"react-router-dom": "^6.3.0"
},
"devDependencies": {
"#types/node": "^18.7.18",
"#types/react": "^18.0.15",
"#types/react-dom": "^18.0.6",
"#typescript-eslint/eslint-plugin": "^5.30.7",
"#typescript-eslint/parser": "^5.30.7",
"#vitejs/plugin-react": "^2.0.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"prettier": "^2.7.1",
"sass": "^1.55.0",
"typescript": "^4.6.4",
"vite": "^3.0.0",
"vite-plugin-svgr": "^2.2.1"
}
}
yarn version of the remote app : 1.22.19
node version of the remote app : v12.0.0
Here is what I get when running the host app with "yarn serve" :
error logs when launching the app
My goal is then to be able to use the component App from the remote app in the host app by importing it like that :
Vue.component("App", () => import("foo/App"));
After running graphql-codegen-esm --config codegen.yml the following message is shown in the console
loadTs is not a function
I add files with my project configuration
package.json
{
"main": "src/index.js",
"type": "module",
"scripts": {
"dev": "concurrently \"nodemon\" \"npm run codegen --watch\"",
"codegen": "graphql-codegen-esm --config codegen.yml"
},
"dependencies": {
"#graphql-tools/load-files": "^6.6.0",
"apollo-server": "^3.10.0",
"graphql": "^16.5.0",
"graphql-modules": "^2.1.0",
"graphql-scalars": "^1.17.0"
},
"devDependencies": {
"#graphql-codegen/add": "^3.2.0",
"#graphql-codegen/cli": "2.11.3",
"#graphql-codegen/graphql-modules-preset": "^2.5.0",
"#graphql-codegen/typescript": "^2.7.2",
"#graphql-codegen/typescript-resolvers": "^2.7.2",
"#tsconfig/node18-strictest-esm": "^1.0.0",
"concurrently": "^7.3.0",
"nodemon": "^2.0.19",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
}
}
codegen.yml
schema: './src/**/*.graphql'
emitLegacyCommonJSImports: false
generates:
./src/graphql/:
preset: graphql-modules
presetConfig:
baseTypesPath: ../generated-types/graphql.ts # Where to create the complete schema types
filename: generated-types/module-types.ts # Where to create each module types
plugins:
- add:
content: '/* eslint-disable */'
- typescript
- typescript-resolvers
tsconfig.json
{
"extends": "#tsconfig/node18-strictest-esm/tsconfig.json",
"ts-node": {
"esm": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Node
v18.7.0
I updated my Angular application from version 9 to 10. Before updating it was working correctly. Now it's getting this error:
ERROR in ./src/assets/scss/argon.scss (./node_modules/css-loader/dist/cjs.js??ref--13-1!./node_modules/postcss-loader/src??embedded!./node_modules/resolve-url-loader??ref--13-3!./node_modules/#angular-devkit/build-angular/node_modules/sass-loader/dist/cjs.js??ref--13-4!./src/assets/scss/argon.scss)
Module build failed (from ./node_modules/#angular-devkit/build-angular/node_modules/sass-loader/dist/cjs.js):
SassError: File to import not found or unreadable: custom/alert.
on line 5 of src/assets/scss/custom/_components.scss
from line 65 of src/assets/scss/argon.scss
>> #import "custom/alert";
I tried so many answers in StackOverflow and GitHub which it would not help me.
I attached my Angular.JSON and Package.JSON:
angular.json:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"argon-dashboard-angular": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"#schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"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.scss",
"src/assets/scss/argon.scss",
"node_modules/sweetalert2/src/sweetalert2.scss"
],
"scripts": [
"node_modules/chart.js/dist/Chart.min.js",
"node_modules/clipboard/dist/clipboard.min.js",
"node_modules/sweetalert2/dist/sweetalert2.js"
]
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "#angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "argon-dashboard-angular:build"
},
"configurations": {
"production": {
"browserTarget": "argon-dashboard-angular:build:production"
}
}
},
"extract-i18n": {
"builder": "#angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "argon-dashboard-angular:build"
}
},
"test": {
"builder": "#angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["src/styles.css"],
"scripts": [],
"assets": ["src/favicon.ico", "src/assets"]
}
},
"lint": {
"builder": "#angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
},
"argon-dashboard-angular-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "#angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "argon-dashboard-angular:serve"
},
"configurations": {
"production": {
"devServerTarget": "argon-dashboard-angular:serve:production"
}
}
},
"lint": {
"builder": "#angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "argon-dashboard-angular",
"schematics": {
"#schematics/angular:component": {
"styleext": "scss"
}
},
"cli": {
"analytics": false
}
}
package.json:
{
"name": "argon-dashboard-angular",
"version": "1.1.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start"
},
"private": true,
"dependencies": {
"#angular/animations": "10.1.1",
"#angular/common": "10.1.1",
"#angular/compiler": "10.1.1",
"#angular/core": "10.1.1",
"#angular/fire": "^6.0.2",
"#angular/forms": "10.1.1",
"#angular/http": "^7.2.16",
"#angular/localize": "^9.0.5",
"#angular/platform-browser": "10.1.1",
"#angular/platform-browser-dynamic": "10.1.1",
"#angular/router": "10.1.1",
"#ckeditor/ckeditor5-angular": "^1.2.3",
"#ckeditor/ckeditor5-build-classic": "^21.0.0",
"#ng-bootstrap/ng-bootstrap": "^6.0.0",
"#sweetalert2/ngx-sweetalert2": "^8.1.1",
"angular-file-uploader": "^7.0.1",
"bootstrap": "^4.5.2",
"chart.js": "2.7.3",
"clipboard": "2.0.4",
"core-js": "3.6.4",
"firebase": "^7.19.1",
"ngx-clipboard": "13.0.0",
"ngx-quill": "^12.0.1",
"ngx-toastr": "12.0.0",
"nouislider": "13.1.1",
"quill": "^1.3.7",
"rxjs": "^7.0.0-beta.5",
"sass-loader": "^10.0.2",
"sweetalert2": "^10.0.2",
"tslib": "2.0.1",
"zone.js": "0.11.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "0.1001.1",
"#angular/cli": "^10.1.1",
"#angular/compiler-cli": "^10.1.1",
"#angular/language-service": "^10.1.1",
"#types/jasmine": "^3.5.8",
"#types/jasminewd2": "^2.0.8",
"#types/node": "^13.7.7",
"codelyzer": "^5.2.1",
"jasmine-core": "^3.5.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "^3.1.1",
"karma-jasmine-html-reporter": "^1.5.2",
"node-sass": "^4.14.1",
"protractor": "7.0.0",
"ts-node": "9.0.0",
"tslint": "6.1.3",
"typescript": "4.0.2"
}
}
I fixed this. I updated all my SCSS files path by manually and build it again. previously as an example there was the path like this which is completely working with a fine in angular 9.
angular 9 import
#import "custom/components";
when I using angular 10 I updated all my SCCS path to like this
#import "./custom/components";
after above-mentioned changes appear project built successfully.
We're using sass to compile scss-files to css. We want to support IE11 including grid using the -ms-grid prefixes. In order to reach that goal, we are using the (npm) postcss autoprefixer on Windows. Our current package.json file looks like this:
{
"name": "project name",
"version": "1.0.0",
"description": "project description",
"main": "index.js",
"scripts": {
"watch-sass": "node-sass scss/style.scss css/style.css --watch",
"compile-sass": "node-sass scss/style.scss css/style.comp.css",
"prefix-css": "postcss --use autoprefixer -b \"last 5 versions\" css/style.comp.css -o css/style.prefix.css",
"compress-css": "node-sass css/style.prefix.css css/style.css --output-style compressed",
"build-css": "npm-run-all compile-sass prefix-css compress-css"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie < 11"
],
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^9.7.3",
"compile-sass": "^1.0.3",
"cross-env": "^6.0.3",
"npm-run-all": "^4.1.5",
"postcss-cli": "^6.1.3",
"prefix-css": "0.0.6"
}
}
In addition to that file we hold a postcss.config.js in the project-directory with the above content:
module.exports = {
plugins: { autoprefixer: { grid: true } }
}
When we now run the build-css script, we would expect the output file to generate the grid prefixes for IE11. All other prefixes are output (e.g. -ms-flex).
Exmaple input:
div.class1 {
display: grid;
}
div.class2 {
display: flex;
}
Output:
div.class1 {
display: grid;
}
div.class2 {
display: -ms-flex;
display: flex;
}
We're aware that the missing autoprefixer option is grid: true, but we do not know how to properly pass that option. What do we have to change in our setu?
(Node version 8.9.4, npm version 5.6.0)
plugins: () => [autoprefixer({ browsers: ["> 1%", "last 2 versions", "not ie <= 8"], grid: true })],
I am using webpack and my config looks like this:
My package.json
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
My webpack.config.js
const package = require('./package.json');
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [autoprefixer({ browsers: package.browserslist, grid: true })],
},
},
I hope It was helpful for you.