Skip to content

Commit

Permalink
archetype-react-app: only enable DLL if dll.config.js exist in client (
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Feb 10, 2017
1 parent 9237886 commit fd9f632
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ var getRootConfig = require("./get-root-config");
var archetype = require("../archetype");
var Path = archetype.Path;
var AppMode = archetype.AppMode;

/* eslint-disable func-style */

function getDllEntry() {
try {
return require(Path.resolve(AppMode.src.client, "dll.config.js")); // eslint-disable-line global-require
} catch (err) {
return {};
}
}
var dllConfig = require(Path.resolve(AppMode.src.client, "dll.config.js"));

var extensions = {};
var baseConfigPath = require.resolve("./webpack.config");
Expand All @@ -36,13 +27,12 @@ extensions[baseConfigPath] = function (config) {

statsPlugin.opts.filename = "../../dll/server/stats.dll.json";
isomorphicPlugin.options.assetsFile = "../../dll/isomorphic-assets.dll.json";
config.entry = {};

return config;
};

var dllConfig = new WebpackConfig().extend(extensions).merge({
entry: getDllEntry(),
entry: dllConfig,
output: {
path: Path.resolve("dll/js"),
filename: "[name].bundle.[hash].js",
Expand Down
22 changes: 13 additions & 9 deletions packages/electrode-archetype-react-app/arch-gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ function makeTasks(gulp) {
task: [".clean.dist", "build-dist-dev-static"]
},

// TODO: fix DLL for webpack 2.0
"build-dist": [".clean.dist", ".clean.dll", "build-dist-min", "build-dist-dll", "build-dist:flatten-l10n",
"build-dist:merge-isomorphic-assets", "copy-dll", "build-dist:clean-tmp"],
"build-dist:merge-isomorphic-assets", "copy-dll", "build-dist:clean-tmp"],

"build-dist-dev-static": {
desc: false,
Expand All @@ -310,11 +309,8 @@ function makeTasks(gulp) {
task: [[".ss-prod-react", ".ss-prod-react-dom"]]
},

"build-dist-dll": () => {
setProductionEnv();
createGitIgnoreDir(Path.resolve("dll"), "Webpack DLL Output dir");
return exec(`webpack --config ${config.webpack}/webpack.config.dll.js --colors`)
},
"build-dist-dll": () => undefined,
"copy-dll": () => undefined,

"build-dist-min": {
dep: [".production-env"],
Expand Down Expand Up @@ -391,8 +387,6 @@ INFO: Individual .babelrc files were generated for you in src/client and src/ser
".clean.etmp": () => shell.rm("-rf", eTmpDir),
".clean.dll": () => shell.rm("-rf", "dll"),

"copy-dll": () => shell.cp("-r", "dll/*", "dist"),

"cov-frontend": () => checkFrontendCov(),
"cov-frontend-50": () => checkFrontendCov("50"),
"cov-frontend-70": () => checkFrontendCov("70"),
Expand Down Expand Up @@ -605,7 +599,17 @@ INFO: Individual .babelrc files were generated for you in src/client and src/ser
task: ["build-lib:client", "build-lib:server", ".build-lib:app-mode"]
}
});
}

if (Fs.existsSync(Path.resolve(AppMode.src.client, "dll.config.js"))) {
tasks = Object.assign(tasks, {
"build-dist-dll": () => {
setProductionEnv();
createGitIgnoreDir(Path.resolve("dll"), "Webpack DLL Output dir");
return exec(`webpack --config ${config.webpack}/webpack.config.dll.js --colors`)
},
"copy-dll": () => shell.cp("-r", "dll/*", "dist")
});
}

return tasks;
Expand Down

0 comments on commit fd9f632

Please sign in to comment.