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
Changes from 1 commit
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
Next Next commit
archetype-react-app: [major] turn off NodeSourcePlugin for prod build
  • Loading branch information
jchip committed Jun 19, 2017
commit a214c88e43412111daf38e9f890f210c62608438
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const assert = require("assert");
const orders = [
"_base-options",
"_entry",
"_node",
"_output",
"_resolve",
"_resolve-loader",
@@ -39,7 +40,8 @@ const orders = [
"_hot",
"_html-reporter",
"_simple-progress",
"_sourcemaps-inline"
"_sourcemaps-inline",
"_node"
];

const files = Fs.readdirSync(__dirname)
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
@@ -14,7 +14,8 @@ const profile = {
_images: { order: 2300 },
_stats: { order: 2400 },
_isomorphic: { order: 2500 },
_pwa: { order: 2600 }
_pwa: { order: 2600 },
_node: { order: 30000 }
}
};