I have a monorepo project that includes a library, several projects, and the main project. My ionic project is in the projects
folder.
I cannot build my ionic project (ionic build
or ng build
) because it imports a module from the main project (src/
) which imports a sass file from a third project in the libs/
folder.
When building with ionic build
, I get the error:
"Can't find stylesheet to import."
@import 'libs/...';
When I build with the ng-cli, I get errors for each of the references to sass files imported from libs/...
seemingly everywhere in the project, even files/modules that aren't imported in this project.
I don't have any issue building other projects that import from the folder.
The package.json
file inside of the ionic project folder includes this snippet:
"config": {
"ionic_webpack": "./webpack.config.js",
"ionic_sass": "./sass.config.js",
"ionic_source_map_type": "source-map"
},
My custom config is pasted below, I've tried variations of including ../../
or not and running ionic build
from both the root directory and the project root:
const useDefaultConfig = require('@ionic/app-scripts/config/sass.config.js');
useDefaultConfig.includePaths.push('libs/path/to/assets/scss');
useDefaultConfig.includePaths.push('libs/path/to/assets/scss/partials');
useDefaultConfig.includePaths.push('../../libs/path/to/assets/scss');
useDefaultConfig.includePaths.push('../../libs/path/to/assets/scss/partials');
useDefaultConfig.includePaths.push('dist/path/to/assets/scss');
useDefaultConfig.includePaths.push('dist/path/to/assets/scss/partials');
useDefaultConfig.includePaths.push('../../dist/path/to/assets/scss');
useDefaultConfig.includePaths.push('../../dist/path/to/assets/scss/partials');
module.exports = useDefaultConfig;
I also tried doing
module.exports = function(){ return useDefualtConfig; };
I added paths to the stylePreprocessorOptions.includePaths
in the project's section of the angular.json
file like so:
"stylePreprocessorOptions": {
"includePaths": [
"libs/path",
"libs/path/assets/scss",
"libs/path/assets/scss/partials",
"dist/path",
"dist/path/assets/scss",
"dist/path/assets/scss/partials"
]
},
I also included the paths in both tsconfig.app.json
and tsconfig.json
.