# @evmts/plugin-webpack

> A webpack plugin for evmts

Latest version **0.0.1** (published 2023-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @evmts/plugin-webpack
pnpm add @evmts/plugin-webpack
yarn add @evmts/plugin-webpack
bun add @evmts/plugin-webpack
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-02-18 |
| First published | 2023-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 10 |
| Unpacked size | 301.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 449 |
| Maintainers | fucory |
| Keywords | babel, plugin, solidity, sol, evmts |

## Links

- npm: https://www.npmjs.com/package/@evmts/plugin-webpack
- Repository: https://github.com/evmts/evmts-monorepo
- Homepage: https://github.com/evmts/evmts-monorepo#readme
- Issues: https://github.com/evmts/evmts-monorepo/issues
- npm.io page: https://npm.io/package/@evmts/plugin-webpack

## Dependencies (10)

- [execa](https://npm.io/package/execa.md) ^7.0.0
- [pathe](https://npm.io/package/pathe.md) ^1.1.0
- [ethers](https://npm.io/package/ethers.md) ^6.0.2
- [globby](https://npm.io/package/globby.md) ^13.1.3
- [webpack](https://npm.io/package/webpack.md) ^5.75.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.0
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.20.15
- [@types/fs-extra](https://npm.io/package/@types/fs-extra.md) ^11.0.1
- [@types/babel-core](https://npm.io/package/@types/babel-core.md) ^6.25.7
- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.20.2

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-02-18

## README

# @evmts/plugin-webpack

A webpack plugin for importing solidity files.

## Instalation

```bash
pnpm i @evmts/plugin-webpack
```

## Webpack usage

Install webpack plugin

```bash
npm i @evmts/plugin-webpack
```

Add to your webpack config

```typescript
import { EvmTsPlugin } from '@evmts/plugin-webpack`
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    new EvmTsPlugin()
  ]
})
```

## NEXT.js Usage

To use in next add to `next.config.js`

```typescript
import { EvmTsPlugin } from "@evmts/webpackPlugin";

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (
    config,
    { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
  ) => {
    config.plugins.push(new EvmTsPlugin({}));
    return config;
  },
};

module.exports = nextConfig;
```

## How it works

Under the hood this plugin will transform solidity imports

When the plugin sees a solidity import it will make the following changes

1. Update the import to import a .ts file

```typescript
- import scripts from './MyScript.sol'
+ import scripts from './MyScript.sol.ts'
```

Insert a new typescript file MyScript.sol.ts as an artifact

```typescript
// MyScript.sol.ts
export default {
  name,
  artifactPath,
  contractPath,
  address,
  abi,
  bytecode,
};
```

The typescript can then go ahead and use the artifacts however it pleases

## Usage in @evmts/core

See full [evms-core](https://github.com/evmts/evmts-monorepo-monorepo/tree/main/docs/evmts) for how it's used in evmts. This plugin can be used in other repos as well.

## Usage in other libraries

Currently only `@evmts/core` is using this but this could easily be adapted or extended for other libraries.

## Autocompletion and Typesafety

For typesafety and autocompletion in your editor add [@evmts/ts-plugin](https://github.com/evmts/evmts-monorepo-monorepo/tree/main/packages/ts-plugin) to your tsconfig.json.

**Custom Ts plugins are for developer experience only**

The typescript compiler does not use custom ts plugins at compile time only in your editor. You will get red squiggly lines telling you something is wrong but it will still compile.

## Other plugins

See [plugin-rollup](https://github.com/evmts/evmts-monorepo-monorepo/tree/main/packages/plugin-rollup) if using vitest, vite, or rollup

---
_Source: https://npm.io/package/@evmts/plugin-webpack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
