aboutsummaryrefslogtreecommitdiffstats
path: root/webpack.config.js
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-09-05 00:36:00 +0000
committers-ol <s-ol@users.noreply.github.com>2018-09-05 00:36:00 +0000
commitece199a92220deaa3212fad30f6026693ae86c63 (patch)
treef576a8c160c8827050ef34f474961d89bdff1ac4 /webpack.config.js
parentsome fixes (diff)
downloadmmm-ece199a92220deaa3212fad30f6026693ae86c63.tar.gz
mmm-ece199a92220deaa3212fad30f6026693ae86c63.zip
polymorphic!
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js45
1 files changed, 32 insertions, 13 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 1ac757b..6783e8f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,22 +1,41 @@
+const fs = require('fs');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
-module.exports = {
+const config = {
context: path.resolve(__dirname, 'app'),
entry: './index.moon',
mode: 'development',
- module: {
- rules: [
- {
- test: /\.moon$/,
- use: [
- 'fengari-loader',
- 'moonscript-loader',
- ]
- },
- ]
- },
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;