Skip to content

Commit

Permalink
Merge pull request #32 from rogeriochaves/fix-recompiling
Browse files Browse the repository at this point in the history
Fix recompiling
  • Loading branch information
rogeriochaves authored Apr 7, 2019
2 parents a281640 + 7512093 commit 1c87b2a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion boilerplate/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ app.use(express.static("build"));
let webpackMiddleware;
if (process.env.NODE_ENV !== "production") {
const webpackDevMiddleware = require("webpack-dev-middleware");
const webpackConfig = require("./webpack.config");
const webpackConfig = require("./webpack.config")(
{},
{ mode: "development" }
);
const compiler = webpack({ ...webpackConfig, mode: "development" });
webpackMiddleware = webpackDevMiddleware(compiler, {
serverSideRender: true,
Expand Down
16 changes: 12 additions & 4 deletions boilerplate/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const config = {
const config = isDev => ({
entry: "./src/index.js",
output: {
path: `${__dirname}/build`,
Expand All @@ -9,10 +9,18 @@ const config = {
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: ["elm-webpack-loader"]
use: [
{
loader: "elm-webpack-loader",
options: {
forceWatch: isDev,
debug: isDev
}
}
]
}
]
}
};
});

module.exports = config;
module.exports = (_, argv) => config(argv.mode !== "production");
15 changes: 11 additions & 4 deletions boilerplate/webpack.config.static.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const HtmlWebpackPlugin = require("html-webpack-plugin");

const config = {
const config = isDev => ({
entry: "./src/index.js",
output: {
path: `${__dirname}/build`,
Expand All @@ -11,7 +11,14 @@ const config = {
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: ["elm-webpack-loader"]
use: [
{
loader: "elm-webpack-loader",
options: {
debug: isDev
}
}
]
}
]
},
Expand All @@ -20,6 +27,6 @@ const config = {
template: "src/index.ejs"
})
]
};
});

module.exports = config;
module.exports = (_, argv) => config(argv.mode !== "production");

0 comments on commit 1c87b2a

Please sign in to comment.