Use webpack-dev-server

This commit is contained in:
Henri Bergius 2018-12-09 21:58:18 +01:00
parent 177dffc681
commit 9896aaf034
2 changed files with 18 additions and 11 deletions

View file

@ -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 <henri.bergius@iki.fi>",
@ -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"
}
}

View file

@ -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,
},
};