Commit 5fb755d4 authored by Justin Woo's avatar Justin Woo

simplify webpack setup

* make webpack dev server work again
* use the purescript compiler output CommonJS modules from src/index.js
* add prebuild "yarn compile" script
* with "yarn dev", you now only need to run a purs ide plugin or run "yarn compile"
parent 40034e50
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"rebuild-set": "spago psc-package-insdhall", "rebuild-set": "spago psc-package-insdhall",
"install-ps": "psc-package install", "install-ps": "psc-package install",
"compile": "pulp --psc-package build", "compile": "pulp --psc-package build",
"prebuild": "yarn compile",
"build": "pulp --psc-package browserify -t dist/bundle.js", "build": "pulp --psc-package browserify -t dist/bundle.js",
"sass": "sass dist/styles/", "sass": "sass dist/styles/",
"predev": "yarn prestart", "predev": "yarn prestart",
......
function _push(a, i) { a.push(i); } function _push(a, i) {
module.exports={ a.push(i);
_push: _push }
}; exports._push = _push;
function _cloneRegex(r) { return new RegExp(r.source, r.flags); } function _cloneRegex(r) {
function _getRegexLastIndex(r) { return r.lastIndex; } return new RegExp(r.source, r.flags);
function _execRegex(r, s) { return r.exec(s); } }
module.exports={ function _getRegexLastIndex(r) {
_cloneRegex: _cloneRegex, return r.lastIndex;
_getRegexLastIndex: _getRegexLastIndex, }
_execRegex: _execRegex function _execRegex(r, s) {
}; return r.exec(s);
}
exports._cloneRegex = _cloneRegex;
exports._getRegexLastIndex = _getRegexLastIndex;
exports._execRegex = _execRegex;
// This file is just a wrapper so that webpack will call our main function // This file is just a wrapper so that webpack will call our main function
require('./Main.purs').main(); require('../output/Main').main();
...@@ -8,33 +8,11 @@ let HtmlWebpackPlugin = require('html-webpack-plugin'); ...@@ -8,33 +8,11 @@ let HtmlWebpackPlugin = require('html-webpack-plugin');
let CleanWebpackPlugin = require('clean-webpack-plugin'); let CleanWebpackPlugin = require('clean-webpack-plugin');
let isWatch = process.argv.some(a => a === '--watch'); let isWatch = process.argv.some(a => a === '--watch');
// TODO: We have agreed to move to spago, but not done it yet
// let spago_sources = async () =>
// exec.quiet(
// "psc-package sources",
// { options: 'strict' }
// ).then(function (res) {
// let sources = res.stdout.split(/\r?\n/);
// sources.pop(); // extra newline at the end of output
// return sources;
// });
let dist = path.join(__dirname, 'dist'); let dist = path.join(__dirname, 'dist');
let src = path.join(__dirname, 'src'); let src = path.join(__dirname, 'src');
let test = path.join(__dirname, 'test'); let test = path.join(__dirname, 'test');
// kill when spago module.exports = (env) =>{
let futured = async () => new Promise((resolve, _) => resolve([]));
module.exports = (env) =>
// spago_sources()
futured()
.then(function (ps_sources) {
ps_sources.push('src/**/*.purs');
// TODO: testing in browser and headless
// if (env === "browser" || env === "headless")
// ps_sources.push('test/Main.purs');
let config = { let config = {
cache: true, cache: true,
mode: 'development', mode: 'development',
...@@ -52,22 +30,6 @@ module.exports = (env) => ...@@ -52,22 +30,6 @@ module.exports = (env) =>
}, },
module: { module: {
rules: [ rules: [
{test: /\.purs$/,
exclude: /(node_modules)/,
use: [
{loader: "purs-loader",
options: {
src: ps_sources,
output: dist,
pscIde: true,
pscIdeClientArgs: {port: 4002},
pscIdeServerArgs: {port: 4002},
pscArgs: {codegen: "js,sourcemaps"},
pscPackage: true,
bundle: false,
watch: isWatch}},
{loader: "source-map-loader"},
]},
{test: /\.css$/, {test: /\.css$/,
exclude: /(node_modules)/, exclude: /(node_modules)/,
use: ["style-loader", "css-loader"]}, use: ["style-loader", "css-loader"]},
...@@ -75,13 +37,13 @@ module.exports = (env) => ...@@ -75,13 +37,13 @@ module.exports = (env) =>
exclude: /(node_modules)/, exclude: /(node_modules)/,
use: [ "file-loader" ]}, use: [ "file-loader" ]},
{test: /\.js$/, {test: /\.js$/,
exclude: /(node_modules)/, exclude: [/(node_modules)/, /(output)/],
use: ["babel-loader", "source-map-loader"]} use: ["babel-loader", "source-map-loader"]}
] ]
}, },
resolve: { resolve: {
modules: [ 'node_modules' ], modules: [ 'node_modules' ],
extensions: [ '.purs', '.js'] extensions: [ '.js']
}, },
plugins: [ plugins: [
// TODO: can we put the checked-in assets in dist somewhere else // TODO: can we put the checked-in assets in dist somewhere else
...@@ -110,4 +72,4 @@ module.exports = (env) => ...@@ -110,4 +72,4 @@ module.exports = (env) =>
console.log("unknown env: ", env); console.log("unknown env: ", env);
} }
return config; return config;
}); };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment