Add boilerplate for building with webpack middleware.

This commit is contained in:
Dillon Kearns 2019-08-13 13:55:13 -07:00
parent a7917cf70e
commit 4bd49a6511
3 changed files with 1272 additions and 109 deletions

79
generator/src/develop.ts Normal file
View File

@ -0,0 +1,79 @@
// import * as webpack from "webpack";
const webpack = require("webpack");
const middleware = require("webpack-dev-middleware");
const express = require("express");
const path = require("path");
export function start() {
const compiler = webpack({
// webpack options
entry: "index.html",
plugins: [],
resolve: {
modules: [path.join(__dirname, "src"), "node_modules"],
extensions: [".js", ".elm", ".scss", ".png"]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.scss$/,
exclude: [/elm-stuff/, /node_modules/],
// see https://github.com/webpack-contrib/css-loader#url
loaders: ["style-loader", "css-loader?url=false", "sass-loader"]
},
{
test: /\.css$/,
exclude: [/elm-stuff/, /node_modules/],
loaders: ["style-loader", "css-loader?url=false"]
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
exclude: [/elm-stuff/, /node_modules/],
loader: "url-loader",
options: {
limit: 10000,
mimetype: "application/font-woff"
}
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
exclude: [/elm-stuff/, /node_modules/],
loader: "file-loader"
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
exclude: [/elm-stuff/, /node_modules/],
loader: "file-loader"
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: [
{ loader: "elm-hot-webpack-loader" },
{
loader: "elm-webpack-loader",
options: {
// add Elm's debug overlay to output?
debug: false,
forceWatch: true
}
}
]
}
]
}
});
const app = express();
app.use(middleware(compiler, { publicPath: "/" }));
// webpack-dev-middleware options
app.listen(3000, () => console.log("Example listening on port 3000!"));
}

1296
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,14 +13,20 @@
"favicons": "^5.4.1",
"glob": "^7.1.4",
"gray-matter": "^4.0.2",
"webpack": "^4.39.2",
"webpack-dev-middleware": "^3.7.0",
"workbox-build": "^4.3.1"
},
"devDependencies": {
"@types/chokidar": "^2.1.3",
"@types/express": "^4.17.0",
"@types/glob": "^7.1.1",
"@types/node": "^12.6.8",
"@types/webpack": "^4.32.1",
"@types/webpack-dev-middleware": "^2.0.3",
"elm": "^0.19.0-no-deps",
"elm-test": "^0.19.0-rev6",
"express": "^4.17.1",
"node-elm-compiler": "^5.0.3",
"parcel-bundler": "^1.12.3",
"typescript": "^3.5.3"