我有一个主要的style.scss文件,尝试将其他.scss文件导入自身。当我使用npm start编译代码时,出现此错误:
ERROR in ./style/style.scss
Module build failed: SyntaxError: C:/Users/XYZ/React/react-project/style/style.scss:
Unexpected token, expected ( (1:8)
@import "_base";
^
我尝试将其放在方括号中
@import("_base");
和
@import("_base.scss");
我得到这个错误:
ERROR in ./style/style.scss Module build failed:
SyntaxError: C:/Users/XYZ/React/react-project/style/style.scss:
Leading decorators must be attached to a class declaration (1:21)
> 1 | @import("_base.scss");
^
这是我的webpack.config.js:
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [
{
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-1']
}
},
],
rules: [{
test: /\.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS
]
}]
},
resolve: {
extensions: ['', '.js', '.jsx', '.scss']
},
devServer: {
historyApiFallback: true,
contentBase: './',
host: 'localhost',
port: 8080
}
};
我是scss的新手,我在网上找到的所有教程都告诉我以这种方式导入文件。怎么了?
答案 0 :(得分:0)
解决了该问题-我迁移到Webpack 2,并将webpack.config.js更改为:
mvn install:install-file -Dfile=Users/myName/eclipse-workspace/HerProject/her.jar -DgroupId=CoreAutomationLibrary -DartifactId=CoreAutomationLibrary -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar