Permalink
Switch branches/tags
v2.2.0-alpha.00000000 v2.1.0-beta.20181015 v2.1.0-beta.20181008 v2.1.0-beta.20181001 v2.1.0-beta.20180924 v2.1.0-beta.20180917 v2.1.0-beta.20180910 v2.1.0-beta.20180904 v2.1.0-beta.20180827 v2.1.0-alpha.20180730 v2.1.0-alpha.20180702 v2.1.0-alpha.20180604 v2.1.0-alpha.20180507 v2.1.0-alpha.20180416 v2.1.0-alpha.00000000 v2.0.6 v2.0.6-rc.1 v2.0.5 v2.0.4 v2.0.3 v2.0.2 v2.0.1 v2.0.0 v2.0-rc.1 v2.0-beta.20180326 v2.0-beta.20180319 v2.0-beta.20180312 v2.0-beta.20180305 v2.0-alpha.20180212 v2.0-alpha.20180129 v2.0-alpha.20180122 v2.0-alpha.20180116 v2.0-alpha.20171218 v2.0-alpha.20171218-plus-left-join-fix v1.2-alpha.20171211 v1.2-alpha.20171204 v1.2-alpha.20171113 v1.2-alpha.20171026 v1.2-alpha.20170901 v1.1.9 v1.1.9-rc.1 v1.1.8 v1.1.7 v1.1.6 v1.1.5 v1.1.4 v1.1.3 v1.1.2 v1.1.1 v1.1.0 v1.1.0-rc.1 v1.1-beta.20170928 v1.1-beta.20170921 v1.1-beta.20170907 v1.1-alpha.20170817 v1.1-alpha.20170810 v1.1-alpha.20170803 v1.1-alpha.20170720 v1.1-alpha.20170713 v1.1-alpha.20170629 v1.1-alpha.20170622 v1.1-alpha.20170608 v1.1-alpha.20170601 v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 v1.0.2 v1.0.1 v1.0 v1.0-rc.3 v1.0-rc.2 v1.0-rc.1 v0.1-alpha beta-20170420 beta-20170413 beta-20170406 beta-20170330 beta-20170323 beta-20170309 beta-20170223 beta-20170216 beta-20170209 beta-20170126 beta-20170112 beta-20170105 beta-20161215 beta-20161208 beta-20161201 beta-20161110 beta-20161103 beta-20161027 beta-20161013 beta-20161006 beta-20160929 beta-20160915 beta-20160908 beta-20160829 beta-20160728
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
156 lines (143 sloc) 4.53 KB
"use strict";
const path = require("path");
const rimraf = require("rimraf");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
// Remove a broken dependency that Yarn insists upon installing before every
// Webpack compile. We also do this when installing dependencies via Make, but
// it"s common to run e.g. `yarn add` manually without re-running Make, which
// will reinstall the broken dependency. The error this dependency causes is
// horribly cryptic, so it"s important to remove it aggressively.
//
// See: https://github.com/yarnpkg/yarn/issues/2987
class RemoveBrokenDependenciesPlugin {
apply(compiler) {
compiler.plugin("compile", () => rimraf.sync("./node_modules/@types/node"));
}
}
let DashboardPlugin;
try {
DashboardPlugin = require("./opt/node_modules/webpack-dashboard/plugin");
} catch (e) {
DashboardPlugin = class { apply() { /* no-op */ } };
}
const proxyPrefixes = ["/_admin", "/_status", "/ts", "/login", "/logout"];
function shouldProxy(reqPath) {
if (reqPath === "/") {
return true;
}
return proxyPrefixes.some((prefix) => (
reqPath.startsWith(prefix)
));
}
// tslint:disable:object-literal-sort-keys
module.exports = (env) => {
let localRoots = [path.resolve(__dirname)];
if (env.dist === "ccl") {
// CCL modules shadow OSS modules.
localRoots.unshift(path.resolve(__dirname, "ccl"));
}
return {
entry: ["./src/index.tsx"],
output: {
filename: "bundle.js",
path: path.resolve(__dirname, `dist${env.dist}`),
},
resolve: {
// Add resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json", ".styl", ".css"],
// First check for local modules, then for third-party modules from
// node_modules.
//
// These module roots are transformed into absolute paths, by
// path.resolve, to ensure that only the exact directory is checked.
// Relative paths would trigger the resolution behavior used by Node.js
// for "node_modules", i.e., checking for a "node_modules" directory in
// the current directory *or any parent directory*.
modules: [
...localRoots,
path.resolve(__dirname, "node_modules"),
],
alias: {oss: path.resolve(__dirname)},
},
module: {
rules: [
{ test: /\.css$/, use: [ "style-loader", "css-loader" ] },
{
test: /\.styl$/,
use: [
"cache-loader",
"style-loader",
"css-loader",
{
loader: "stylus-loader",
options: {
use: [require("nib")()],
},
},
],
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 10000,
},
},
{ test: /\.html$/, loader: "file-loader" },
{
test: /\.js$/,
include: localRoots,
use: ["cache-loader", "babel-loader"],
},
{
test: /\.tsx?$/,
include: localRoots,
use: [
"cache-loader",
"babel-loader",
{ loader: "ts-loader", options: { happyPackMode: true } },
],
},
// All output ".js" files will have any sourcemaps re-processed by "source-map-loader".
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
],
},
plugins: [
new RemoveBrokenDependenciesPlugin(),
// See "DLLs for speedy builds" in the README for details.
new webpack.DllReferencePlugin({
manifest: require(`./protos.${env.dist}.manifest.json`),
}),
new webpack.DllReferencePlugin({
manifest: require("./vendor.oss.manifest.json"),
}),
new CopyWebpackPlugin([{ from: "favicon.ico", to: "favicon.ico" }]),
new DashboardPlugin(),
],
// https://webpack.js.org/configuration/stats/
stats: {
colors: true,
chunks: false,
},
devServer: {
contentBase: path.join(__dirname, `dist${env.dist}`),
index: "",
proxy: {
// Note: this shouldn't require a custom bypass function to work;
// docs say that setting `index: ''` is sufficient to proxy `/`.
// However, that did not work, and may require upgrading to webpack 4.x.
"/": {
secure: false,
target: process.env.TARGET,
bypass: (req) => {
if (shouldProxy(req.path)) {
return false;
}
return req.path;
},
},
},
},
};
};