css - Chrome 没有将我浏览器中的更改传送到我的本地文件
问题描述
问题:
当我在 chrome 开发工具中编辑 CSS 时,我正在尝试使用 chrome 工作区/源映射来更新我的 sass 部分。Chrome 正在从我在 webpack 中设置的源映射中检测我的 sass 部分,但给我错误“对此文件的更改未保存到文件系统”。当我尝试从 chrome 开发工具的源选项卡中保存更改时。
此外,在 chrome 开发工具的样式选项卡中,尽管 chrome 知道哪些属性连接到哪些 sass 部分,但更改样式并不会更新源选项卡中的部分文件。
尽管 sass 部分显示为 chrome 开发工具中映射的源,并且尽管我设置了工作站,但 Chrome 并未将浏览器中的更改传达给我的本地文件。
至今:
- 我在 chrome 中设置了一个工作区并添加了项目的文件夹
- 禁用了我所有的 chrome 扩展
- 确保“启用 CSS 源地图”在 chrome 设置中为真
我相信问题可能出在我的 webpack 配置上,因为这是我第一次制作自定义 webpack 配置,我基本上是在摆弄它直到它起作用。它可能(可能不是)是依赖项的问题,所以我还将添加我的 package.json 文件。
在 chrome 检查器中检测到 Sass 部分
Sass 部分显示在源选项卡中:
错误信息
Webpack 配置文件:
const path = require('path')
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: ['@babel/polyfill', './src/index.js'],
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
publicPath: '/'
},
devServer: {
contentBase: 'dist',
historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/public/index.html'
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
})
],
module: {
rules: [
{
test: /\.sass$/,
use: [
"style-loader",
{ loader: 'css-loader', options: { sourceMap: true} },
{ loader: 'sass-loader', options: { sourceMap: true } }
],
},
{
test: /\.css$/,
use: [
"style-loader",
"css-loader"
]
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
"babel-loader"
]
}
]
}
}
包.json:
{
"name": "css",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"css-loader": "^3.2.0",
"eslint": "^6.5.1",
"eslint-plugin-react": "^7.16.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.0",
"style-loader": "^1.0.0",
"webpack": "^4.41.1",
"webpack-cli": "^3.3.9",
"webpack-dev-server": "^3.8.2"
},
"dependencies": {
"@babel/polyfill": "^7.6.0",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-router-dom": "^5.1.2"
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"env": {
"browser": true,
"node": true
}
},
"eslintIgnore": [
"webpack.config.js"
]
}
解决方案
Chrome 不再支持此功能 :( 相关问题被标记为“无法修复”。
https://bugs.chromium.org/p/chromium/issues/detail?id=996226
推荐阅读
- ruby-on-rails - 在模型集合上急切加载移动翻译
- unity3d - Unity 项目已擦除,但文件夹仍处于层次结构中
- asp.net-core - 在 ASP.NET Core 5 中向 N 层应用程序添加缓存层而不是多次调用数据库
- java-11 - Java 11 的 jaxb2-maven-plugin XJC 错误
- swift - SearchBar 在激活并输入之前不会返回结果
- fpga - 如何控制 Kristen FPGA 实现多余的寄存器?
- class - 使用 append() 时处理“IllegalArgumentException:参数不是数组”错误;
- go - 半球打印体积为零
- python - 无法在numpy中对浮点矩阵执行矩阵乘法
- python - Python Selenium 编辑星标密码字段