Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archetype-react-app: [major] turn off NodeSourcePlugin for prod build #384

Merged
merged 2 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const assert = require("assert");
const orders = [
"_base-options",
"_entry",
"_node",
"_output",
"_resolve",
"_resolve-loader",
Expand Down Expand Up @@ -39,7 +40,8 @@ const orders = [
"_hot",
"_html-reporter",
"_simple-progress",
"_sourcemaps-inline"
"_sourcemaps-inline",
"_node"
];

const files = Fs.readdirSync(__dirname)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";

const archetype = require("electrode-archetype-react-app/config/archetype");
const webpack = require("webpack");
const FunctionModulePlugin = require("webpack/lib/FunctionModulePlugin");
const logger = require("electrode-archetype-react-app/lib/logger");

module.exports = function(options) {
const config = options.currentConfig;

if (
process.env.NODE_ENV === "production" &&
config.target === undefined &&
archetype.webpack.enableNodeSourcePlugin !== true
) {
logger.info("Disabling NodeSourcePlugin for production");
// disable NodeSourcePlugin by setting a custom target, and then apply the
// plugins the original web target would've applied.
// will be much easier once webapck with node: false option is released
const output = config.output;
config.target = () => undefined;
config.plugins = [
new webpack.JsonpTemplatePlugin(output),
new FunctionModulePlugin(output),
new webpack.LoaderTargetPlugin("web")
].concat(config.plugins);
} else {
logger.info("Not disabling NodeSourcePlugin. NODE_ENV:", process.env.NODE_ENV);
}

return {};
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const profile = {
_images: { order: 2300 },
_stats: { order: 2400 },
_isomorphic: { order: 2500 },
_pwa: { order: 2600 }
_pwa: { order: 2600 },
_node: { order: 30000 }
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from "react";
import "es6-promise";
import "isomorphic-fetch";

const HTTP_BAD_REQUEST = 400;
const HTTP_OK = 200;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from "react";
import "es6-promise";
import "isomorphic-fetch";
import RecordForm from "./record-form";

const HTTP_BAD_REQUEST = 400;
Expand Down
2 changes: 0 additions & 2 deletions samples/universal-react-node/src/client/middleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "es6-promise";
import "isomorphic-fetch";
const HTTP_BAD_REQUEST = 400;
const HTTP_OK = 200;
let token;
Expand Down