Webpack @ import cannot use the alias alias

I used the project created by vue-cli 2.x, and then in the .vue file

<style>
@import "@/assets/icon/iconfont.css";
</style>

will report an error: Module build failed: Error: Failed to find"~ @ / assets/icon/iconfont.css"

even if I add ~ , I will still report an error: Module build failed: Error: Failed to find"@ / assets/icon/iconfont.css"

does any boss know how to solve it? Thank you very much!

Jun.23,2022

@ import'~ @ / assets/icon/iconfont.css';

add [~] before the alias

resolve: {
    alias: {
        '@': path.resolve(__dirname, 'src'),
        'static': path.resolve(__dirname, 'src/static'),
        'assets': path.resolve(__dirname, 'src/assets'),
        'components': path.resolve(__dirname, 'src/components')
    }
}

CSS loader interprets the url of a non-root path as a relative path, and prefixes it as a module path

.

Source: https://www.jianshu.com/p/c3a...


webpack.resolve.alias configure

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e67969-4d344.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e67969-4d344.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?