alleyinteractive / sasslint-loader

sass lint loader for webpack
MIT License
17 stars 6 forks source link

Issue with Node.js 4.1.0, sass-lint 1.2.2, and Webpack 1.12.2 #5

Open davegomez opened 9 years ago

davegomez commented 9 years ago

I got the following error trying to use sasslint-loader as preloader in my Webpack config file using the suggested Webpack configuration over the .js files.

Syntax "js" is not supported yet, sorry
Hash: 8f21d01e87f9ca7b3987
Version: webpack 1.12.2
Time: 634ms
    + 1 hidden modules

ERROR in ./lib/src/index.js
Module build failed: TypeError: Cannot read property 'toString' of undefined
    at module.exports (/project_path/node_modules/sass-lint/lib/groot.js:25:89)
    at Function.sassLint.lintText (/project_path/node_modules/sass-lint/index.js:36:13)
    at lint (/project_path/node_modules/sasslint-loader/index.js:21:25)
    at Object.module.exports (/project_path/node_modules/sasslint-loader/index.js:99:7)
dmachat commented 9 years ago

Thanks for the report. This was probably one of the few things I punted on while waiting for some fixes in sass-lint, but I will revisit this loader as a whole.

DanPurdy commented 9 years ago

@dmachat if there's anything in sass-lint holding you back get an issue up and we'll look into it as a priority.. Integrations like this are really great and we'll be looking to support here as best as we can.

dmachat commented 9 years ago

@davegomez that's my shoddy doc work. You need to limit this loader to scss or sass files, eg https://github.com/alleyinteractive/sasslint-loader/blob/master/example/webpack.config.js#L18. I've also updated the README.

@DanPurdy caught up today and it doesn't look like there's anything actually blocking me on your end anymore. sasstools/sass-lint#62 is still an issue for stray tabs, but I've removed them from tests for now and can live without them.

davegomez commented 9 years ago

Srry @dmachat but I'm not getting even an error output now.

I have tried all the loader options and this is my webpack config now:

/* eslint indent: 0 */
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers

const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const merge = require('webpack-merge');

const TARGET = process.env.npm_lifecycle_event;
const LIB = path.resolve(__dirname, 'lib/src');
const BIN = path.resolve(__dirname, 'bin');

const common = {
  entry: LIB,
  resolve: {
    extensions: ['', '.js']
  },
  output: {
    path: BIN,
    filename: 'js/main.js'
  }
};

if (TARGET === 'start' || !TARGET) {
  module.exports = merge(common, {
    devtool: 'eval-source-map',
    module: {
      preLoaders: [
        { test: /\.js?$/, loaders: ['eslint', 'jscs'], include: LIB },
        {
          test: /\s[a|c]ss$/,
          exclude: /node_modules/,
          loader: 'sasslint'
        }
      ],
      loaders: [
        {
          test: /\.js?/,
          loaders: ['babel'],
          include: LIB
        },
        {
          test: /\.scss?$/,
          loader: ExtractTextPlugin.extract('style-loader',
            'css-loader?sourceMap' +
            '!autoprefixer-loader?browsers=last 2 version' +
            '!sass-loader?outputStyle=expanded&sourceMap&sourceMapContents')
        }
      ]
    },
    sasslint: {
      configFile: './.sass-lint.yml',
      emitError: true,
      emitWarning: true,
      failOnError: true
    },
    stats: {
      children: false
    },
    plugins: [
      new ExtractTextPlugin('bin/css/main.css', {
        allChunks: true
      }),
      new BrowserSyncPlugin({
        host: 'localhost',
        port: 3000,
        server: { baseDir: ['./bin'] },
        files: ['bin/*.html']
      })
    ]
  });
}

I also tried writing the sasslint option before the preLoaders option but it didn't work either.

The console is clear while I get some errors and warnings using the sass-lint CLI tools.

I don't understand what i'm doing wrong here.

Also, this is how I'm downloading the module since the NPM support doesn't work yet:

"sasslint-loader": "git://github.com/alleyinteractive/sasslint-loader",