@dr.pogodin/react-utils
Version:
Collection of generic ReactJS components and utils
36 lines (35 loc) • 1.89 kB
JavaScript
;
// Development Webpack config for ReactJS libraries.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = configFactory;
/* eslint-disable import/no-extraneous-dependencies */
const node_path_1 = __importDefault(require("node:path"));
const webpack_1 = __importDefault(require("webpack"));
const webpack_merge_1 = require("webpack-merge");
const lib_base_1 = __importDefault(require("./lib-base"));
function configFactory(ops) {
const { outputPath = 'build/development' } = ops;
return (0, webpack_merge_1.merge)((0, lib_base_1.default)(Object.assign(Object.assign({}, ops), { babelEnv: 'development', cssLocalIdent: '[package]___[path][name]___[local]___[hash:base64:6]', mode: 'development', outputPath: node_path_1.default.resolve(__dirname, ops.context, outputPath) })), {
plugins: [
new webpack_1.default.DefinePlugin({
// Dev. build of the library wraps modules inside eval() statements,
// hiding BUILD_INFO literals from the host code's Webpack build, thus
// leaving them undefined. As a work around, let's get it via global
// window object.
BUILD_INFO: 'window.__DEV_BUILD_INFO__',
'process.env.BABEL_ENV': JSON.stringify('development'),
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.REACT_GLOBAL_STATE_DEBUG': JSON.stringify(true),
}),
],
snapshot: {
// This enforces Webpack to watch for possible changes in node_modules
// dependencies, which is a great convenience in library-centric dev
// workflows.
managedPaths: [],
},
});
}