带有extract-text-plugin的sass-loader不输出文件

时间:2016-12-23 13:54:05

标签: css sass webpack

我已将webpack.config.js配置如下:

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');

// plugins
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  context: path.join(__dirname, "src"),
  devtool: debug ? "inline-sourcemap" : null,
  entry: "./js/init.js",
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015', 'stage-0'],
          plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties',],
        }
      },
      {
        test: /\.json$/,
        include: /node_modules/,
        loader: 'json-loader'
      },
      {
        test: /\.scss$/,
        loaders: ExtractTextPlugin.extract(
          'style',
          'css!sass'
        )
      }
    ]
  },
  output: {
    path: __dirname + "/src/",
    filename: "app.js"
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
    new ExtractTextPlugin('default.css'),
  ],
  devServer: {
    port: 3000,
    historyApiFallback: {
      index: 'index.html'
    }
  },
  sassLoader: {
    includePaths: [path.resolve(__dirname, "src/css/sass")]
  },
  resolve: {
    alias: {
      '#': path.resolve(__dirname, 'src/js'),
      '!': path.resolve(__dirname, 'src/css/sass')
    }
  },
};

这是我的文件结构:

- src
-- css
--- sass
---- default.scss
-- js
-- index.html

然而,当我运行default.css时,我没有看到我的webpack dev server文件导出到任何地方。它不适用于webpack dev server吗?

编辑:只是运行webpack也不起作用。

0 个答案:

没有答案
相关问题