@cimpress/react-components
Version:
React components to support the MCP styleguide
79 lines • 2.9 kB
JavaScript
var _a, _b;
import * as path from 'path';
import * as webpack from 'webpack';
// @ts-expect-error no up-to-date types available for case-sensitive-paths-webpack-plugin
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import Dotenv from 'dotenv-webpack';
import '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 main
new CaseSensitivePathsPlugin(),
new webpack.ProvidePlugin({ process: 'process/browser' }),
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
VERSION: (_a = process.env.npm_package_version) !== null && _a !== void 0 ? _a : '',
COMMIT_SHA: (_b = process.env.CI_COMMIT_SHA) !== null && _b !== void 0 ? _b : '',
}),
new Dotenv({ path: './build.env' }),
new HtmlWebpackPlugin({
title: 'React Components',
template: 'index.html',
}),
],
};
export default config;
//# sourceMappingURL=webpack.config.js.map