1.4.0 • Published 16 days ago

replace-absolute-path v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

replace-absolute-path

  • usage:
const fs = require('fs');
const replacePath = require('replace-absolute-path');

(async function () {
  const srcDir = path.resolve(__dirname, '../src');
  const libDir = path.resolve(__dirname, '../lib');
  replacePath({
    inputDir: srcDir,
    outputDir: libDir,
    // includeExts: replacePath.DEFAULT_EXTS.concat(['.md']),
    afterReplaced: () => {
      console.log('--------------------------------------------------------------------------');
      console.log('|  all files import statements has been transformed to relative path ^_^  |');
      console.log('--------------------------------------------------------------------------');
    },
  });
})();

now your file import statements changed

// if current file position is /src/components/Editor/index.js
// config file position is /src/config.js

import xx from 'configs/xx';
// change to
import xx from '../../configs/xx';

export { default as xx } from 'configs/xx';
// change to
export { default as xx } from '../../configs/xx';

import { xx } from 'configs/xx';
// change to
import { xx } from '../../configs/xx';