Skip to content

Commit

Permalink
Minimal elm app with webpack run and build
Browse files Browse the repository at this point in the history
  • Loading branch information
ceddlyburge committed Jun 22, 2018
0 parents commit f2f2318
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
elm-stuff/
node_modules/
tmp/
dist/
aws-config.json
npm-debug.*
15 changes: 15 additions & 0 deletions elm-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"src"
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "progessive-elm-app",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"build": "webpack --mode=production",
"start": "webpack-dev-server --port 3000 --mode=development"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack-cli": "^3.0.8"
}
}
4 changes: 4 additions & 0 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Html

main : Html.Html msg
main = Html.text "Hello World"
11 changes: 11 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Elm SPA example</title>
</head>
<body>
<div id="main"></div>
<script src="/app.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

// Require index.html so it gets copied to dist
require('./index.html');

var Elm = require('./Main.elm');
var mountNode = document.getElementById('main');

// .embed() can take an optional second argument. This would be an object describing the data we need to start a program, i.e. a userID or some token
var app = Elm.Main.embed(mountNode);
37 changes: 37 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var path = require("path");

module.exports = {
entry: {
app: [
'./src/index.js'
]
},

output: {
path: path.resolve(__dirname + '/dist'),
filename: '[name].js',
},

module: {
rules: [
{
test: /\.html$/,
exclude: /node_modules/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
loader: 'elm-webpack-loader?verbose=true&warn=true',
}
],

noParse: /\.elm$/,
},

devServer: {
inline: true,
stats: { colors: true },
},

};

0 comments on commit f2f2318

Please sign in to comment.