aboutsummaryrefslogtreecommitdiffstats
path: root/webpack.config.js
blob: 6783e8fb45aeeea96a13ac2162aae011e132d6b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require('fs');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
  context: path.resolve(__dirname, 'app'),
  entry: './index.moon',
  mode: 'development',
  plugins: [
    new HtmlWebpackPlugin({ title: 'MMM: lunar low-gravity scripting playground' }),
  ],
};

const dependencies = {
  'svg.js': 'svg.js',
};
fs.readdirSync(config.context).forEach(file => {
  if (file.endsWith('.moon') && !file.endsWith('.server.moon')) {
    const basename = file.replace(/(\.client)?\.moon$/, '');
    dependencies[`app.${basename}`] = `./${file}`;
  }
});

config.module = {
  rules: [
    {
      test: /\.moon$/,
      use: [
        {
          loader: 'fengari-loader',
          options: {
            dependencies,
          },
        },
        'moonscript-loader',
      ]
    },
  ]
};

module.exports = config;