@doonce/add-vue-suffix
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@doonce/add-vue-suffix

🔨Give some vue files ,find reference and add .vue suffix;(Useful for some project migrate to vite from webpack)

English | 中文

Install

npm i -D @doonce/add-vue-suffix

or

yarn add @doonce/add-vue-suffix -D

Usage

with cli

npx @doonce/add-vue-suffix --resolveConifg ./path/to/resolve-config.js

or

{
  "scripts": {
    "add-vue-suffix": "add-vue-suffix --resolveConifg ./path/to/resolve-config.js"
  }
}
// webpack.config.js
const path = require('path')

module.exports={
  input:'./src/index.js',

  ...,

  resolve:{
    extensions: ['.js', '.vue', '.json'],
    alias: {
      '@': path.resolve('src'),
      Api: path.resolve('src/api'),
      Api2: path.resolve('src/api2'),
      Assets: path.resolve('src/assets'),
      Base: path.resolve('src/base'),
      Config: path.resolve('src/config'),
      Components: path.resolve('src/components'),
      Directives: path.resolve('src/directives'),
      Plugins: path.resolve('src/plugins'),
      Routes: path.resolve('src/routes'),
      Sass: path.resolve('src/sass'),
      Services: path.resolve('src/services'),
      Stores: path.resolve('src/stores'),
      Utils: path.resolve('src/utils'),
      Views: path.resolve('src/views')
  }
}
  • If you use vue-cli or other not emit webpack config cli,you can just create a js file that export a object that contain resolve property like above.

with function

import addVueSuffix from '@doonce/add-vue-suffix'

addVueSuffix({
  withAST = false, // add-vue-suffix use regexp to replace import/export/import() by default;If you got some error,set this to true,it will use babel to replace import/export/import();
  patterns = ['src/**/*.vue', 'src/**/*.js'], // some file may be import vue file;search `vue` and `js` under `src` by default;
  globbyOptions = {}, // custom globby options, it will override default globby options;
  resolveConfig = {}, // https://www.npmjs.com/package/enhanced-resolve;https://webpack.js.org/configuration/resolve/#resolve
  debug = false,// set true will not rewrite file;
})

NPM

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 BryanAdamss@foxmail.com.
This project is MIT licensed.

Contributors

Thanks goes to these wonderful people (emoji key):


GuangHui

📆

This project follows the all-contributors specification. Contributions of any kind welcome!

Readme

Keywords

Package Sidebar

Install

npm i @doonce/add-vue-suffix

Weekly Downloads

1

Version

1.1.2

License

MIT

Unpacked Size

51.8 kB

Total Files

35

Last publish

Collaborators

  • bryanadamss