SCSS Import Relative to Root

后端 未结 5 1052
不思量自难忘°
不思量自难忘° 2020-12-09 01:12

I\'m in the process refactoring an Angular application and as I\'m moving components around to new directory locations, I\'m finding that dealing @import paths

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 01:41

    solution for angular-cli is to add stylePreprocessorOptions to .angular-cli.json.

    {
        "apps": [{
            ...
            "stylePreprocessorOptions": {
                "includePaths": [
                    "./app/global-styles"
                ]
            },
            ...
        }]
    }
    

    if you use server-side rendering remember to add this for both ssr and main app build - otherwise you will get NodeInvocationException: Prerendering failed because of error: Error: Cannot find module 'C:\Users\...\ClientApp\dist-server\main.bundle.js'

    {
        "apps": [{
                ...
                "outDir": "dist",
                "stylePreprocessorOptions": {
                    "includePaths": [
                        "./app/global-styles"
                    ]
                },
                ...
            },
            {
                ...
                "name": "ssr",
                "outDir": "dist-server",
                "stylePreprocessorOptions": {
                    "includePaths": [
                        "./app/global-styles"
                    ]
                },
                ...
            }
        ]
    }
    

提交回复
热议问题