jeffling / wallaby-webpack

webpack preprocessor for wallabyjs
25 stars 8 forks source link

How to configure usage of webpack's raw-loader? #11

Closed RainerAtSpirit closed 9 years ago

RainerAtSpirit commented 9 years ago

Use case: all of our components are including html fragments via the raw-loader e.g.

    template = require('raw!./code-mirror.html'),

In that situation wallaby throws an an error.

wallaby.js started
core v1.0.73
...
Runtime error: Error: Cannot find module "raw!./code-mirror.html"
Finished executing 5 affected test(s)

We are using the default configuration for webpack in wallaby.js, which works well for files that doesn't use the raw-loader.

var wallabyWebpack = require('wallaby-webpack');
var webpackPostprocessor = wallabyWebpack({});

module.exports = function () {

  return {
    files: [
      ...
      { pattern: 'src/**/*.js', load: false },
      { pattern: '!src/**/*Spec.js', load: false }
    ],

    tests: [
      { pattern: 'src/**/*Spec.js', load: false }
    ],

    preprocessors: {
  //    '**/*.js': file => babel.transform(file.content, { sourceMap: true })
    },

    postprocessor: webpackPostprocessor,

    bootstrap: function () {
      window.__moduleBundler.loadTests();
    }
  };
};
RainerAtSpirit commented 9 years ago

Figured it out. Just make sure to include the .html files in files.

var wallabyWebpack = require('wallaby-webpack');
var webpackPostprocessor = wallabyWebpack({});

module.exports = function() {

    return {
        files: [
            {pattern: 'src/**/*.js', load: false},
            // Include .html files 
            {pattern: 'src/**/*.html', load: false},
            {pattern: '!src/**/*Spec.js', load: false}
        ],

        tests: [
            {pattern: 'src/**/*Spec.js', load: false}
        ],

        preprocessors: {
            //    '**/*.js': file => babel.transform(file.content, { sourceMap: true })
        },

        postprocessor: webpackPostprocessor,

        bootstrap: function() {
            window.__moduleBundler.loadTests();
        }
    };
};