Struggling to load CSS files in my VueJs project. I recently integrated the less-loader and sass-loader, both of which are functioning correctly. However, when attempting to add a CSS file within a SASS file or directly in the main.js using import, the file cannot be located.
Here's my current approach:
SASS:
@import "../../../../node_modules/pnotify/dist/PNotifyBrightTheme.css";
or JavaScript:
import 'module/pnotify/dist/PNotifyBrightTheme.css'
webpack.base.config:
resolve: {
extensions: ['.js', '.vue', '.json', '.css'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'module': resolve('node_modules')
}
},
module: {
rules: [{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: { importLoaders: 1 }
},
'postcss-loader'
]
}]
}
postcssrc.js file:
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
"autoprefixer": {}
}
}
Installed modules:
"css-loader": "^0.28.11",
"postcss-load-config": "^1.2.0",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.1.4",
"postcss-url": "^7.2.1",
"style-loader": "^0.21.0",
The library containing the CSS file:
"pnotify": "^4.0.0-alpha.4",
Encountered Exception:
in ./src/assets/scss/index.scss
Module build failed: Error: Failed to find '../../../../node_modules/pnotify/dist/PNotifyBrightTheme.css'
in [
/src/assets/scss
]
at resolveModule.catch.catch (/node_modules/postcss-import/lib/resolve-id.js:35:13)
at <anonymous>
@ ./src/assets/scss/index.scss 4:14-212 13:3-17:5 14:22-220
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
If anyone has insights on how to resolve this issue, your help would be greatly appreciated. Feeling quite desperate :(