gpt4 book ai didi

javascript - Webpack 不会查找 SCSS 中的更改

转载 作者:行者123 更新时间:2023-12-05 06:41:46 26 4
gpt4 key购买 nike

我正在尝试在一个大的 main.js 中制作 css 和 js,但它现在正在监听此更改我看不到错误,终端不显示错误可以很好地响应。我使用的 webpack 版本是 1.13.1。这是我的依赖项列表:

“开发依赖”:{

"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"css-loader": "^0.25.0",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-loader": "^1.5.0",
"eslint-plugin-import": "^1.15.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "^6.3.0",
"node-sass": "^3.10.0",
"sass-loader": "^4.0.2",
"style-loader": "^0.13.1"

}, "依赖项": {

"electron": "^1.4.1",
"electron-prebuilt": "^1.4.1",
"fs": "0.0.1-security",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-redux": "^4.4.5",
"react-router": "^2.8.1",
"redux": "^3.6.0",
"redux-form": "^6.0.5",
"redux-promise": "^0.5.3",
"webpack": "^1.13.1"

我的文件结构是:

  • 来源
    • 应用程序
      • 组件
      • 风格
      • app.jsx

这是我的网络包文件:

const path = require("path");
const webpack = require("webpack");

module.exports = {
context: path.resolve("src/app/"),
entry: "./app.jsx",
output: {
path: path.resolve("src/"),
publicPath: "src/",
filename: "main.js"
},
devServer: {
contentBase: "./"
},
module: {
preLoaders: [
{
test: /(\.jsx$|\.js$)/,
exclude: /node_modules/,
loader: "eslint-loader"
}
],
loaders: [
{
test: /(\.jsx$|\.js$)/,
exclude: /node_modules/,
loaders: ["babel-loader"]
}, {
test: /\.scss$/,
exclude: /node_modules/,
loader: "style-loader!css-loader!sass-loader"
}
]
},
eslint: {
configFile: ".eslintrc"
},
resolve: {
extensions: [
"", ".js", ".jsx"
]
},
watch: true,
devtool: "inline-source-map"
};

最佳答案

我相信你已经安装了必要的装载机。如果没有,

npm install --save-dev sass-loader css-loader style-loader

然后,

loaders: [
// ...
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
}
]

然后在你的js文件中引入你的scss文件:

require('../sass/mystyle.scss');

关于javascript - Webpack 不会查找 SCSS 中的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39663113/

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