From 9896aaf034b6ad0c326336d2e273ec0aa539ebd2 Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Sun, 9 Dec 2018 21:58:18 +0100 Subject: [PATCH] Use webpack-dev-server --- package.json | 6 +++--- webpack.config.js | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3d35d51..6871b27 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "webpack", "pretest": "eslint index.js lib/*.js elements/*.js infodisplay/*.js events/*.js", - "start": "http-server dist/ -p 3000 -s -c-1", + "start": "webpack-dev-server", "test": "npm run build" }, "author": "Henri Bergius ", @@ -30,9 +30,9 @@ "eslint": "^4.12.0", "eslint-config-airbnb-base": "^12.1.0", "eslint-plugin-import": "^2.8.0", - "http-server": "^0.11.0", "msgflo-nodejs": "^0.11.1", "webpack": "^4.0.0", - "webpack-cli": "^3.0.0" + "webpack-cli": "^3.0.0", + "webpack-dev-server": "^3.1.10" } } diff --git a/webpack.config.js b/webpack.config.js index 9a37eaa..ae98387 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,3 +1,4 @@ +const path = require('path'); const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { @@ -7,11 +8,12 @@ module.exports = { calendar: './events/calendar.js', }, output: { - path: __dirname, - filename: 'dist/lib/[name].js', + path: path.resolve(__dirname, 'dist'), + filename: 'lib/[name].js', library: '[name]', libraryTarget: 'umd', }, + mode: 'production', module: { rules: [ { @@ -31,27 +33,27 @@ module.exports = { new CopyWebpackPlugin([ { from: '**/index.html', - to: 'dist/', + to: './', }, { from: '**/*.svg', - to: 'dist/', + to: './', }, { from: 'theme/*', - to: 'dist/', + to: './', }, { from: 'node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js', - to: 'dist/vendor/webcomponentsjs/webcomponents-lite.js', + to: './vendor/webcomponentsjs/webcomponents-lite.js', }, { from: 'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js', - to: 'dist/vendor/webcomponentsjs/custom-elements-es5-adapter.js', + to: './vendor/webcomponentsjs/custom-elements-es5-adapter.js', }, { from: 'node_modules/plotly.js/dist/plotly.min.js', - to: 'dist/vendor/plotly.js/plotly.min.js', + to: './vendor/plotly.js/plotly.min.js', }, ]), ], @@ -64,4 +66,9 @@ module.exports = { node: { fs: 'empty', }, + devServer: { + host: process.env.HOST || 'localhost', + port: 3000, + inline: true, + }, };