Webpack 拋出錯誤
GET http://localhost:8080/sass/main.scss net::ERR_ABORTED 404 (Not Found)
但在啟動服務器時,它用 CSS 加載頁面。scss 匯入到 js 中
import '../sass/main.scss';
網路包配置:
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/js/controller.js',
plugins: [
new HtmlWebpackPlugin({
template: './index.html',
}),
],
module: {
rules: [
{
test: /\.html$/i,
use: ['html-loader'],
},
{
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
}
index.html模板的head部分:這里的css鏈接完全沒有影響,只在js里面匯入
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-
scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
href="https://fonts.googleapis.com/css?
family=Nunito Sans:400,600,700"
rel="stylesheet"
/>
<link rel="shortcut icon" href="/src/img/favicon.png"
type="image/x-icon" />
<link rel="stylesheet" href="/src/saas/main.css" />
<title></title>
<script type="module" src="/src/js/controller.js"></script>
</head>
可能出了什么問題?
uj5u.com熱心網友回復:
解決。我洗掉了 index.html 中腳本的鏈接
<script type="module" src="src/js/controller.js"></script>
并且錯誤消失了。(入口點和 html 模板已經在配置中指定)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/425754.html
標籤:javascript 网页包 粗鲁的
上一篇:Webpack差異構建
下一篇:什么是“.js.map”檔案?
