Skip to content

Commit

Permalink
fix issues related to prettier/prettier#719
Browse files Browse the repository at this point in the history
  • Loading branch information
olivoil committed Apr 2, 2018
1 parent 47cec27 commit 062bbfe
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 82 deletions.
56 changes: 30 additions & 26 deletions config/webpack/blocks/cssModules.js
Expand Up @@ -58,37 +58,41 @@ function getRule(
}

function cssModules() {
return ({ fileType, platform, webpack }) =>
/* : { fileType: Function, platform: Platform, webpack: Object } */
return (
{
const { NODE_ENV } = process.env;
fileType,
platform,
webpack
} /* : { fileType: Function, platform: Platform, webpack: Object } */
) => {
const { NODE_ENV } = process.env;

fileType.add({
"text/x-css-vendor": /node_modules.*\.css$/
});

const config = {
module: {
rules: [
getRule({ fileType, platform, NODE_ENV, modules: true }),
getRule({ fileType, platform, NODE_ENV, modules: false })
]
}
};
fileType.add({
"text/x-css-vendor": /node_modules.*\.css$/
});

if (platform === "browser" || platform === "desktop") {
return Object.assign({}, config, {
plugins: [
new ExtractTextPlugin({
filename: "styles.css",
allChunks: true
})
]
});
const config = {
module: {
rules: [
getRule({ fileType, platform, NODE_ENV, modules: true }),
getRule({ fileType, platform, NODE_ENV, modules: false })
]
}

return config;
};

if (platform === "browser" || platform === "desktop") {
return Object.assign({}, config, {
plugins: [
new ExtractTextPlugin({
filename: "styles.css",
allChunks: true
})
]
});
}

return config;
};
}

module.exports = cssModules;
86 changes: 43 additions & 43 deletions config/webpack/blocks/getEntry.js
Expand Up @@ -4,53 +4,53 @@ const Glob = require("glob");
const { NODE_ENV } = process.env;

function getEntry(entry /* : ?(string | Object | Array<*>) */) {
return ({ fileType, platform }) /* : { entry: any } */ =>
/* : { platform: Platform, fileType: Function } */
{
if (entry) return { entry };
return (
{ fileType, platform } /* : { platform: Platform, fileType: Function } */
) /* : { entry: any } */ => {
if (entry) return { entry };

if (platform === "browser" || platform === "desktop") {
return {
entry: {
bundle: [
"sanitize.css/sanitize.css",
"tachyons-clears",
"tachyons-display",
"tachyons-flexbox",
"tachyons-position",
"tachyons-spacing",
"tachyons-text-align",
"tachyons-vertical-align",
"tachyons-widths",
"./src/styles/fonts.css",
"./src/styles/app.css",
`./src/index.${platform}.js`
]
}
};
} else if (platform === "server") {
// construction inspired by:
// https://github.com/webpack/webpack/issues/1189#issuecomment-156576084
const serverEntry =
NODE_ENV === "development" ? ["webpack/hot/poll?500"] : [];
const server = {
"server.js": serverEntry.concat(["./server/index.js"])
};
if (platform === "browser" || platform === "desktop") {
return {
entry: {
bundle: [
"sanitize.css/sanitize.css",
"tachyons-clears",
"tachyons-display",
"tachyons-flexbox",
"tachyons-position",
"tachyons-spacing",
"tachyons-text-align",
"tachyons-vertical-align",
"tachyons-widths",
"./src/styles/fonts.css",
"./src/styles/app.css",
`./src/index.${platform}.js`
]
}
};
} else if (platform === "server") {
// construction inspired by:
// https://github.com/webpack/webpack/issues/1189#issuecomment-156576084
const serverEntry =
NODE_ENV === "development" ? ["webpack/hot/poll?500"] : [];
const server = {
"server.js": serverEntry.concat(["./server/index.js"])
};

// Get server layouts and web components for compilation
// and place at build/layouts and build/components
// since hapi-react-views requires templates at runtime
const serverLayouts = Glob.sync("./server/views/!(*_test.js)*");
serverLayouts.forEach(file => {
const target = `views/${file.split("/").pop()}`;
server[target] = file;
});
// Get server layouts and web components for compilation
// and place at build/layouts and build/components
// since hapi-react-views requires templates at runtime
const serverLayouts = Glob.sync("./server/views/!(*_test.js)*");
serverLayouts.forEach(file => {
const target = `views/${file.split("/").pop()}`;
server[target] = file;
});

return { entry: server };
}
return { entry: server };
}

throw new Error("Unsupported platform and no entry passed");
};
throw new Error("Unsupported platform and no entry passed");
};
}

module.exports = getEntry;
24 changes: 11 additions & 13 deletions config/webpack/blocks/getTarget.js
@@ -1,21 +1,19 @@
// @flow

function getTarget(target /* : ?string */) {
return ({ platform }) =>
/* : { platform: Platform } */
{
if (target) return { target };
return ({ platform } /* : { platform: Platform } */) => {
if (target) return { target };

if (platform === "browser") {
return { target: "web" };
} else if (platform === "desktop") {
return { target: "electron-renderer" };
} else if (platform === "server") {
return { target: "node" };
}
if (platform === "browser") {
return { target: "web" };
} else if (platform === "desktop") {
return { target: "electron-renderer" };
} else if (platform === "server") {
return { target: "node" };
}

throw new Error("Unsupported platform and no target passed");
};
throw new Error("Unsupported platform and no target passed");
};
}

module.exports = getTarget;

0 comments on commit 062bbfe

Please sign in to comment.