From 1fa61d10a8fd1587f4895688a77c531072ef5bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 24 May 2017 13:21:28 +0200 Subject: [PATCH] hot reloading in lay --- lay/bin/server.js | 4 +++- lay/package.json | 20 ++++++++++++++++++++ lay/web/index.html | 2 +- lay/webpack.config.js | 21 ++++++++++++++++++++- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/lay/bin/server.js b/lay/bin/server.js index dead07f..1f887e9 100644 --- a/lay/bin/server.js +++ b/lay/bin/server.js @@ -6,11 +6,13 @@ const compiler = Webpack(webpack_config); const server = new WebpackDevServer(compiler, { contentBase: webpack_config.output.path, + publicPath: webpack_config.output.publicPath, disableHostCheck: true, stats: { colors: true }, - headers: {} + headers: {}, + hot: true, }); const listen_interface = "0.0.0.0"; diff --git a/lay/package.json b/lay/package.json index 3f01ce4..b32ff20 100644 --- a/lay/package.json +++ b/lay/package.json @@ -29,11 +29,31 @@ "devDependencies": { "babel-core": "^6.24.1", "babel-loader": "^7.0.0", + "babel-preset-env": "^1.5.1", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "css-loader": "^0.28.2", + "react-hot-loader": "^3.0.0-beta.7", "style-loader": "^0.18.1", "webpack": "^2.6.0", "webpack-dev-server": "^2.4.5" + }, + "babel": { + "presets": [ + [ + "env", + { + "targets": { + "chrome": 52, + "firefox": 53 + }, + "modules": false + } + ], + "react" + ], + "plugins": [ + "react-hot-loader/babel" + ] } } diff --git a/lay/web/index.html b/lay/web/index.html index 6879276..d59b58c 100644 --- a/lay/web/index.html +++ b/lay/web/index.html @@ -7,6 +7,6 @@
- + diff --git a/lay/webpack.config.js b/lay/webpack.config.js index a8b21bf..3005c04 100644 --- a/lay/webpack.config.js +++ b/lay/webpack.config.js @@ -1,15 +1,34 @@ +const webpack = require('webpack'); const path = require('path'); module.exports = { + devtool: 'inline-source-map', entry: { 'index': [ + 'react-hot-loader/patch', + 'webpack-dev-server/client?http://localhost:2000', + 'webpack/hot/only-dev-server', './src', ] }, output: { path: path.resolve(__dirname,'web'), - publicPath: '/web/', + publicPath: '/public/', filename: 'js/[name].js' + }, + plugins: [ + new webpack.HotModuleReplacementPlugin(), + new webpack.NamedModulesPlugin() + ], + module: { + rules: [ + { test: /\.jsx?$/, use: [ 'babel-loader', ], exclude: /node_modules/ }, + { test: /\.css$/, use: [ 'style-loader', 'css-loader?modules', ], }, + ], + }, + resolve: { + extensions: [".js","jsx",".json"], + mainFiles: ["index"] } }