@cimpress/react-components
Version:
React components to support the MCP styleguide
106 lines • 4.18 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const webpack = __importStar(require("webpack"));
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
const dotenv_webpack_1 = __importDefault(require("dotenv-webpack"));
require("webpack-dev-server");
const config = {
entry: process.env.NODE_ENV === 'production'
? ['./index.tsx']
: [
// Bundle the client for webpack-dev-server
// and connect to the provided endpoint
'webpack-dev-server/client?http://localhost:8080',
// the entry point of our app
'./index.tsx',
],
// Webpack config options on how to obtain modules
resolve: {
alias: {
// @cimpress/react-components requires will be searched in src folder, not in node_modules
'@cimpress/react-components/lib': path.resolve(__dirname, 'src/'),
'@cimpress/react-components': path.resolve(__dirname, 'src/index.ts'),
},
extensions: ['', '.js', '.jsx', '.ts', '.tsx'],
},
context: path.resolve(__dirname, 'docs'),
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
devtool: 'inline-source-map',
devServer: {
hot: true,
// enable HMR on the server
historyApiFallback: true,
// play nice with reloading on routes other than index
},
module: {
rules: [
{
test: /\.(tsx|jsx|ts|js)?$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
{
test: /\.md/,
use: ['raw-loader'],
},
{
test: /\.(eot|svg|ttf|woff(2)?)(\?v=\d+\.\d+\.\d+)?/,
use: ['url-loader'],
},
],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: process.env.BASE_NAME || '/',
// necessary for HMR to know where to load the hot update chunks
},
plugins: [
// Catches issues with file casing before they get merged into master
new case_sensitive_paths_webpack_plugin_1.default(),
new webpack.ProvidePlugin({ process: 'process/browser' }),
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
VERSION: process.env.npm_package_version,
COMMIT_SHA: (_a = process.env.CI_COMMIT_SHA) !== null && _a !== void 0 ? _a : '',
}),
new dotenv_webpack_1.default({ path: './build.env' }),
new html_webpack_plugin_1.default({
title: 'React Components',
template: 'index.html',
}),
],
};
exports.default = config;
//# sourceMappingURL=webpack.config.js.map