404(未找到)SCSS 与 Webpack

404 (Not Found) SCSS with Webpack

Webpack 抛出错误

GET http://localhost:8080/sass/main.scss net::ERR_ABORTED 404 (Not Found)

但在启动服务器时它加载了带有 css 的页面。 scss 用

导入到 js
import '../sass/main.scss';

webpack 配置:

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'],
  },
  ],
 },
}

head part of index.html template: link to 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>

可能出了什么问题?

已解决。我删除了 link 到 index.html

中的脚本
<script type="module" src="src/js/controller.js"></script>

错误消失了。 (入口点和 html 模板已在配置中指定)