From 6f10f6397bd23c6b193a4f2d1a28c6d5b531fdb3 Mon Sep 17 00:00:00 2001 From: Gabriel Perales Date: Wed, 15 Mar 2017 23:07:04 +0100 Subject: [PATCH 1/8] webpack configured --- index.html | 19 +++++++++---------- package.json | 11 +++++++++-- webpack.config.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 webpack.config.js diff --git a/index.html b/index.html index 34a8c52..3afe10e 100644 --- a/index.html +++ b/index.html @@ -7,18 +7,17 @@ - + - + - diff --git a/package.json b/package.json index 200eeb1..cdcfd4c 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,19 @@ "private": true, "version": "0.1.0", "description": "", - "scripts": {}, + "scripts": { + "build": "webpack -p", + "start": "webpack-dev-server" + }, "keywords": [], "author": "", "license": "ISC", "dependencies": {}, "devDependencies": { + "copy-webpack-plugin": "^4.0.1", "del": "2.2.2", + "elm": "^0.18.0", + "elm-webpack-loader": "^4.2.0", "gulp": "3.9.1", "gulp-bump": "2.4.0", "gulp-elm": "0.6.1", @@ -24,6 +30,7 @@ "gulp-uglify": "2.0.0", "gulp-util": "3.0.7", "gulp-watch": "4.3.6", - "live-server": "github:jackfranklin/live-server#ignore-assets-with-spa-option" + "live-server": "github:jackfranklin/live-server#ignore-assets-with-spa-option", + "webpack": "^2.2.1" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..a570d75 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,44 @@ +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const path = require('path'); +const webpack = require('webpack'); + +module.exports = { + entry: './src/App.elm', + output: { + library: 'Elm', + path: path.join(__dirname, 'build'), + filename: 'js/App.js', + }, + devServer: { + inline: true, + }, + module: { + rules: [{ + test: /\.elm$/, + exclude: [/elm-stuff/, /node_modules/], + loader: 'elm-webpack-loader', + }], + }, + plugins: [ + new CopyWebpackPlugin([ + { + from: 'style.css', + }, + { + from: 'img/*', + }, + { + from: 'js/*', + }, + { + from: 'vendor/**/*', + }, + { + from: 'content/**/*', + }, + { + from: 'index.html', + } + ]) + ], +}; From 18ba6ec012c955acb7c921ca70820b8677c85db5 Mon Sep 17 00:00:00 2001 From: Gabriel Perales Date: Wed, 15 Mar 2017 23:11:44 +0100 Subject: [PATCH 2/8] removed gulp and gulp configuration --- Gulpfile.js | 79 ---------------------------------------------------- package.json | 16 ----------- 2 files changed, 95 deletions(-) delete mode 100644 Gulpfile.js diff --git a/Gulpfile.js b/Gulpfile.js deleted file mode 100644 index 3aeaf31..0000000 --- a/Gulpfile.js +++ /dev/null @@ -1,79 +0,0 @@ -var gulp = require('gulp'); -var liveServer = require('live-server'); -var $ = require('gulp-load-plugins')({}); -var del = require('del'); - -function watchElmAndRun(...args) { - return gulp.watch('**/*.elm', args); -} - -gulp.task('build', function() { - return gulp.src('src/App.elm') - .pipe($.plumber({ - errorHandler: $.notify.onError({ sound: false, message: 'Elm error' }) - })) - .pipe($.elm.bundle('App.js', { - warn: true, - debug: true - })) - .pipe(gulp.dest('build/')); -}); - -gulp.task('prod:elm', ['prod:clean'], function() { - return gulp.src('src/App.elm') - .pipe($.elm.bundle('App.js')) - .pipe($.uglify()) - .pipe(gulp.dest('dist/build')); -}); - -gulp.task('prod:clean', function() { - return del(['dist/**/*']); -}); - -gulp.task('prod:vendor', ['prod:clean'], function() { - return gulp.src('vendor/*').pipe(gulp.dest('dist/vendor')); -}); - -gulp.task('prod:html', ['prod:clean'], function() { - return gulp.src('index.html') - .pipe($.rename('200.html')) - .pipe(gulp.dest('dist')); -}); - -gulp.task('prod:css', ['prod:clean'], function() { - return gulp.src('style.css').pipe(gulp.dest('dist')) -}) - -gulp.task('prod:img', ['prod:clean'], function() { - return gulp.src('img/*').pipe(gulp.dest('dist/img')) -}) - -gulp.task('prod:js', ['prod:clean'], function() { - return gulp.src('js/*').pipe(gulp.dest('dist/js')) -}) - -gulp.task('prod:content', ['prod:clean'], function() { - return gulp.src('content/**/*', { base: 'content' }).pipe(gulp.dest('dist/content')) -}) -gulp.task('deploy', [ - 'prod:vendor', 'prod:html', 'prod:css', - 'prod:js', 'prod:img', 'prod:content', 'prod:elm' -], function() { - $.util.log('Deploying version: ', require('./package.json').version); - return $.surge({ - project: './dist', - domain: 'elmplayground.com' - }); -}); - -gulp.task('start', ['build'], function() { - watchElmAndRun('build'); -}); - -gulp.task('serve', function() { - liveServer.start({ - open: false, - ignore: /elm-stuff/, - file: 'index.html' - }); -}); diff --git a/package.json b/package.json index cdcfd4c..2b3ec81 100644 --- a/package.json +++ b/package.json @@ -13,24 +13,8 @@ "dependencies": {}, "devDependencies": { "copy-webpack-plugin": "^4.0.1", - "del": "2.2.2", "elm": "^0.18.0", "elm-webpack-loader": "^4.2.0", - "gulp": "3.9.1", - "gulp-bump": "2.4.0", - "gulp-elm": "0.6.1", - "gulp-filter": "4.0.0", - "gulp-load-plugins": "1.2.4", - "gulp-notify": "2.2.0", - "gulp-plumber": "1.1.0", - "gulp-rename": "1.2.2", - "gulp-shell": "0.5.2", - "gulp-surge": "0.1.0", - "gulp-tag-version": "1.3.0", - "gulp-uglify": "2.0.0", - "gulp-util": "3.0.7", - "gulp-watch": "4.3.6", - "live-server": "github:jackfranklin/live-server#ignore-assets-with-spa-option", "webpack": "^2.2.1" } } From 7601b3fe66ad2f59da2492965cc2f6b8a6583bb1 Mon Sep 17 00:00:00 2001 From: Gabriel Perales Date: Thu, 16 Mar 2017 12:38:40 +0100 Subject: [PATCH 3/8] added debug option to webpack --- webpack.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index a570d75..d15b25d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,7 +16,8 @@ module.exports = { rules: [{ test: /\.elm$/, exclude: [/elm-stuff/, /node_modules/], - loader: 'elm-webpack-loader', + loader: 'elm-webpack-loader' + + (process.env.NODE_ENV !== 'production' ? '?+debug' : ''), }], }, plugins: [ From 1fbbdfe0c64fd63a79d70766f1638ad3680b9336 Mon Sep 17 00:00:00 2001 From: Gabriel Perales Date: Sun, 19 Mar 2017 20:30:01 +0100 Subject: [PATCH 4/8] Concat all js files. Closes #14 --- .gitignore | 1 - index.html | 2 -- js/ports.js => src/js/app.js | 3 +++ webpack.config.js | 18 ++++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) rename js/ports.js => src/js/app.js (85%) diff --git a/.gitignore b/.gitignore index 763b1c9..249aee8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ elm-stuff/ build/ node_modules/ -dist/ diff --git a/index.html b/index.html index 3afe10e..ef340d5 100644 --- a/index.html +++ b/index.html @@ -6,9 +6,7 @@ - -