You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VueJS项目用Webpack Encore构建SCSS时依赖未找到错误求助

Fixing Your VueJS + Symfony Encore Style Compilation Error

Hey there, I know you’ve been stuck on this for two days—let’s get this sorted out quickly! The core issue is a small misconfiguration in your App.vue file, plus a couple of quick dependency checks. Here’s what to do:

1. Fix the Style Tag in App.vue

Your biggest problem is the lang attribute in your style tag. You wrote <style lang="scss-loader">, but lang should specify the preprocessor language (not the webpack loader name). scss-loader is the tool Webpack uses to process SCSS files, but Vue just needs to know the language is SCSS.

Update your App.vue style section to this:

<style lang="scss">
/* Import Font Awesome Icons Set */
$fa-font-path: 'font-awesome/fonts/';
@import 'font-awesome/scss/font-awesome.scss';

/* Import Simple Line Icons Set */
$simple-line-font-path: 'simple-line-icons/fonts/';
@import 'simple-line-icons/scss/simple-line-icons.scss';

/* Import Bootstrap Vue Styles */
@import 'bootstrap-vue/dist/bootstrap-vue.css';

// Import Main styles for this application
@import './assets/scss/style.scss'; // Added .scss suffix for clarity
</style>

(I also added the .scss suffix to your main style import—this helps Webpack resolve the file more reliably.)

2. Verify Required Dependencies Are Installed

Symfony Encore’s enableSassLoader() needs the right preprocessor packages to work. Run this command to make sure you have the latest, supported tools (we’ll use sass instead of the deprecated node-sass):

yarn add sass-loader sass --dev

3. Clean Cache & Reinstall Dependencies

Sometimes cached node modules or lock files can cause weird issues. Let’s start fresh:

# Delete node_modules and lock file
rm -rf node_modules
rm yarn.lock

# Reinstall all dependencies
yarn install

4. Restart the Development Server

Now run your dev command again:

yarn run dev --watch

Why This Worked

That long, confusing error message was because Vue was trying to use scss-loader as the language identifier, which made Webpack look for a non-existent chain of loaders. By fixing the lang attribute to scss, you’re telling Vue to use the SCSS preprocessor setup you already configured with Encore’s enableSassLoader().

Your Webpack config looks good—enableVueLoader() and enableSassLoader() are correctly set up, so once the style tag is fixed and dependencies are in place, everything should compile smoothly.

内容的提问来源于stack exchange,提问作者Speedy059

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:18:29