thoer metn
thoer metn

Reputation: 61

Webpack does not look for changes in SCSS

I'm trying to make the css and js in one big main.js but it is now listen for this changes I can't see the error, the terminal does not show error works fine for react. the webpack version that I'm using is 1.13.1. here is the list of my dependencies:

"devDependencies": {

"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"

}, "dependencies": {

"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"

}

and my file structure is:

And here is my web pack file:

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"
};

Upvotes: 3

Views: 2005

Answers (1)

JFAP
JFAP

Reputation: 3717

I believe you have installed the necessary loaders. If not,

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

then,

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

then require your scss file in your js file:

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

Upvotes: 1

Related Questions