1
爲什麼我收到此錯誤?我還將引導文件導入到主custom.scss文件中。不確定這是否會產生任何問題?Webpack不讀@符號 - 意想不到的字符'@'(4:0)
嘗試使用SCSS裝載機 的WebPack時,我收到此錯誤:
Unexpected character '@' (4:0)
You may need an appropriate loader to handle this file type.
|
|
| @import "_bootstrap";
| @import "spinner";
| @import "navigations";
@ ./js/app.js 5:0-30
Here is my webpack.config.js script:
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './js/app.js',
output: {
path: __dirname,
filename: 'js/bundle.js'
},
watch: true,
module: {
rules: [
{
test: /\.(jpe?g|png|gif|svg)$/i,
//test: /\.(png|jpg)$/,
use: 'file-loader'
}
],
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
{
test: /.scss?$/,
loader: 'style-loader!css-loader!sass-loader'
}
]
},
};
Here is my require script located in my app.js file:
require('../scss/custom.scss');
它的工作!語法工作。除了無法讀取@符號外,我還在加載所有包含引導程序的圖像文件(即woff,woff2,eot,ttf,svg)時遇到問題。我找到了一個解決圖像問題的教程(https://www.youtube.com/watch?v=4vZrWNWrEsU)。使用您提供的新語法並加載圖像的URL加載器,我能夠解決這兩個問題。謝謝!! –