gpt4 book ai didi

javascript - 如何在SCSS + Parcel.js中使用背景图像

转载 作者:行者123 更新时间:2023-12-01 17:23:49 24 4
gpt4 key购买 nike

我正在尝试使用parcel.js和SCSS来使用背景图像,但是得到:

Uncaught SyntaxError: Unexpected token < 7d6454d814b6ce2e1592d3937c337ef3.js:1



或有时得到:

Cannot read property 'js' of null



这是我的scss:
.hero{
background-image: url('../../images/2ndpaper.jpg');
}

这是我的js:
import "../styles/index.scss";
import paperbg from "../images/2ndpaper.jpg";

这是我的package.json:
 {
"name": "development",
"version": "1.0.0",
"description": "CB PC - Web Development",
"main": "index.js",
"scripts": {
"dev": "parcel src/index.html",
"build": "parcel build src/index.html --out-dir prod"
},
"keywords": [
"client",
"website"
],
"author": "Designs by Harp",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"parcel-bundler": "^1.11.0"
},
"dependencies": {
"bootstrap-4-grid": "^2.4.1",
"gsap": "^2.0.2",
"jshint": "^2.10.1",
"sass": "^1.17.2"
}
}

有什么事吗

最佳答案

我会添加新的npm脚本,尝试按照Parcel documentation中的建议添加“--public-url ./”

"build2": "parcel build src/index.html --public-url prod"

关于javascript - 如何在SCSS + Parcel.js中使用背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54892273/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com