Tony Wei Tony Wei - 1 year ago 88
Sass (Sass) Question

Sass have no effects using webpack

So i use web pack, new to this, here is my package.json

"name": "postronix",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"css-loader": "^0.24.0",
"node-sass": "^3.9.0",
"sass-loader": "^4.0.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.1"
"dependencies": {
"babel-polyfill": "^6.13.0",
"jquery": "^3.1.0"


const webpack = require('webpack');

module.exports = {
entry: './src/app.js',
output: {
path: './bin',
filename: 'app.bundle.js',
module: {
loaders: [
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
test: /\.scss$/,
loaders: ["style", "css", "sass"]
plugins: [



$font-stack: Helvetica, sans-serif;
$primary-color: #333;

ul {

font: 100% $font-stack;
color: $primary-color;
background-color: #282828;


var css = require("!css!sass!./file.scss");
import 'babel-polyfill';
import cats from './cats';
import $ from 'jquery';

const ul = $('<ul></ul>').appendTo('body');
for (const cat of cats) {


<!DOCTYPE html>
<meta charset="utf-8">
<script src="bin/app.bundle.js" charset="utf-8"></script>

after execute "webpack" in cli, it was not showing any errors,
chrome console not find any error too. but why scss not affected, colors don't change, font don't change.

btw i found this code inside "transpiled" js, app.bundle.js:

exports.push([, "ul {\n font: 100% Helvetica, sans-serif;\n color: #333;\n background-color: #282828; }\n", ""]);

please help

Answer Source

You're using two loader configurations to handle SASS files:

  • the one in webpack.config.js (loaders: ["style", "css", "sass"])
  • one in the JS file: require("!css!sass!./file.scss")

The latter seems to take precedence, but doesn't include the style loader, which is the one that inserts a <style> element into your HTML. Without it, you need to somehow manually inject the styles into the HTML.

The simplest solution is to just use require('./file.scss')

More information here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download