# gmall **Repository Path**: zdyumath/gmall ## Basic Information - **Project Name**: gmall - **Description**: 高高的商城 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-22 - **Last Updated**: 2025-07-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Babel Plugin for Replacing Import Sources This is a [Babel](https://babeljs.io/) plugin that replaces import sources in JavaScript/TypeScript files during the compilation process. ## Features - **Source Replacement:** Replaces specified import sources with alternative sources. - **Environment Support:** Supports different environments (development, production). - **Custom Rules:** Allows defining custom replacement rules using regular expressions. ## Installation ```bash npm install --save-dev babel-plugin-replace-import-source ``` ## Usage ### Configuration Add the plugin to your Babel configuration file (`babel.config.js` or `.babelrc`): ```js module.exports = { plugins: [ [ 'replace-import-source', { // Environment-specific configuration development: { // Replace 'react' with 'preact' 'react': 'preact', }, production: { // Replace 'moment' with 'dayjs' 'moment': 'dayjs', }, // Global configuration (applies to all environments) global: { // Replace 'lodash' with '@material-ui/utils' 'lodash': '@material-ui/utils', }, }, ], ], }; ``` ### Example #### Input ```js import React from 'react'; import moment from 'moment'; import _ from 'lodash'; ``` #### Output (Development) ```js import React from 'preact'; import moment from 'dayjs'; import _ from '@material-ui/utils'; ``` #### Output (Production) ```js import React from 'preact'; import moment from 'dayjs'; import _ from '@material-ui/utils'; ``` > Note: The environment is determined by the `BABEL_ENV` or `NODE_ENV` environment variable. ## License MIT