title: Webpack 4 loader rule include condition not working
body: <p><strong>Project Structure</strong></p>
  
  <pre><code>hello-world-imba
    + dist
       - index.html
  
    + src
       + backend
           - server.imba
       + frontend
           - client.imba
  
    - package.json       
    - webpack.config.js
  </code></pre>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>{
    "name": "hello-world-imba",
    "version": "1.0.0",
    "description": "Hello World for Imba",
    "scripts": {
      "start": "imba src/backend/server.imba",
      "build": "webpack"
    },
    "keywords": [
      "imba"
    ],
    "author": "Jignesh Gohel",
    "license": "ISC",
    "dependencies": {
      "express": "^4.16.4",
      "imba": "^1.4.1",
      "webpack": "^4.29.0"
    },
    "devDependencies": {
      "webpack-cli": "^3.2.1"
    }
  }
  </code></pre>
  
  <p><strong>webpack.config.js</strong></p>
  
  <pre><code>const path = require('path');
  
  module.exports = {
      mode: 'development',
      entry: {
        app: path.resolve(__dirname, 'src/frontend/client.imba')
      },
      module: {
          rules: [
              {
                  use: 'imba/loader',
  
                  // Skip any files outside of project's following
                  // directories:
                  // `src/frontend`
                  include: [
                      path.resolve(__dirname, 'src/frontend')
                  ],
  
                  // Only run `.imba` files through Imba Loader
                  test: /.imba$/
              }
          ]
      },
      resolve: {
          extensions: [".imba",".js", ".json"]
      },
      output: {
          filename: "client.js",
          path: path.resolve(__dirname, 'dist')
      }
  }
  </code></pre>
  
  <p><strong>src/backend/server.imba</strong></p>
  
  <pre><code>var express = require 'express'
  var server = express()
  
  server.use(express.static('./dist'))
  
  var port = process:env.PORT or 8080
  
  var server = server.listen(port) do
      console.log 'server is running on port ' + port
  </code></pre>
  
  <p><strong>src/frontend/client.imba</strong></p>
  
  <pre><code>tag App
  
      def render
          &lt;self&gt;
              &lt;p&gt; "Hello World"
  
  Imba.mount &lt;App&gt;
  </code></pre>
  
  <p><strong>dist/index.html</strong></p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html class="no-js" lang=""&gt;
    &lt;head&gt;
      &lt;title&gt;Hello World&lt;/title&gt;
      &lt;meta charset="utf-8"&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;script src="client.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>with that code when I run <code>npm run build</code> I get following error:</p>
  
  <pre><code>$ npm run build
  
  &gt; hello-world-imba@1.0.0 build /jwork/imba/hello-world-imba
  &gt; webpack
  
  Hash: 0a9b1aaa377161766be2
  Version: webpack 4.29.0
  Time: 121ms
  Built at: 01/25/2019 7:22:15 PM
      Asset      Size  Chunks             Chunk Names
  client.js  4.63 KiB     app  [emitted]  app
  Entrypoint app = client.js
  [./src/frontend/client.imba] 220 bytes {app} [built]
      + 1 hidden module
  
  ERROR in ./node_modules/imba/imba.imba 1:25
  Module parse failed: Unexpected token (1:25)
  You may need an appropriate loader to handle this file type.
  &gt; module.exports = require "./src/imba/index.imba"
   @ ./src/frontend/client.imba 1:11-26
  npm ERR! code ELIFECYCLE
  npm ERR! errno 2
  npm ERR! hello-world-imba@1.0.0 build: `webpack`
  npm ERR! Exit status 2
  npm ERR! 
  npm ERR! Failed at the hello-world-imba@1.0.0 build script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/jignesh/.npm/_logs/2019-01-25T13_52_15_689Z-debug.log
  </code></pre>
  
  <p><strong>Detailed Logs</strong></p>
  
  <pre><code>$ cat /home/jignesh/.npm/_logs/2019-01-25T13_52_15_689Z-debug.log
  0 info it worked if it ends with ok
  1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
  2 info using npm@6.7.0
  3 info using node@v10.14.0
  4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
  5 info lifecycle hello-world-imba@1.0.0~prebuild: hello-world-imba@1.0.0
  6 info lifecycle hello-world-imba@1.0.0~build: hello-world-imba@1.0.0
  7 verbose lifecycle hello-world-imba@1.0.0~build: unsafe-perm in lifecycle true
  8 verbose lifecycle hello-world-imba@1.0.0~build: PATH: &lt;PATHS HERE&gt;
  9 verbose lifecycle hello-world-imba@1.0.0~build: CWD: /jwork/imba/hello-world-imba
  10 silly lifecycle hello-world-imba@1.0.0~build: Args: [ '-c', 'webpack' ]
  11 silly lifecycle hello-world-imba@1.0.0~build: Returned: code: 2  signal: null
  12 info lifecycle hello-world-imba@1.0.0~build: Failed to exec build script
  13 verbose stack Error: hello-world-imba@1.0.0 build: `webpack`
  13 verbose stack Exit status 2
  13 verbose stack     at EventEmitter.&lt;anonymous&gt; (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
  13 verbose stack     at EventEmitter.emit (events.js:182:13)
  13 verbose stack     at ChildProcess.&lt;anonymous&gt; (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
  13 verbose stack     at ChildProcess.emit (events.js:182:13)
  13 verbose stack     at maybeClose (internal/child_process.js:962:16)
  13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
  14 verbose pkgid hello-world-imba@1.0.0
  15 verbose cwd /jwork/imba/hello-world-imba
  16 verbose Linux 3.13.0-135-generic
  17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
  18 verbose node v10.14.0
  19 verbose npm  v6.7.0
  20 error code ELIFECYCLE
  21 error errno 2
  22 error hello-world-imba@1.0.0 build: `webpack`
  22 error Exit status 2
  23 error Failed at the hello-world-imba@1.0.0 build script.
  23 error This is probably not a problem with npm. There is likely additional logging output above.
  24 verbose exit [ 2, true ]
  </code></pre>
  
  <p>After doing some trial and error I found that the culprit is following portion under <code>module.rules</code></p>
  
  <pre><code>include: [
    path.resolve(__dirname, 'src/frontend')
  ],
  </code></pre>
  
  <p>removing which <code>npm run build</code> successfully generates the bundle and running the server using <code>npm run start</code> I can access the application too.</p>
  
  <p>Can anybody please help me understand what is the issue and how to get it resolved? The path specified looks correct assuming it works for <code>entry.app</code> option. The webpack documentation for the <a href="https://webpack.js.org/configuration/module/#condition" rel="nofollow noreferrer">Condition</a> says</p>
  
  <blockquote>
    <p>{ include: Condition }: The Condition must match. The convention is to
    provide a string or array of strings here, but it's not enforced.</p>
  </blockquote>
  
  <p>but it doesn't convey anything meaningful in clear manner to me. Please see that I am newbie to Node-based development so please bear with me if what I have asked sounds silly.</p>