This package has been deprecated

    Author message:

    WARNING: This package has been renamed to @truffle/solidity-loader.

    truffle-solidity-loader

    0.1.32 • Public • Published

    truffle-solidity-loader

    A Webpack loader that allows importing a solidity contract directly. Importing returns a truffle artifact json object. This allows smart contract development with Hot Reloading support and enables migrations to automatically re-run on change. When running a production build, contracts will be bundled into main bundle for easy deployment.

    Example

    const Web3 = require("web3"); // currently compatible up to web3@1.0.0-beta.37
    const provider = new Web3.providers.HttpProvider("http://localhost:8545");
    const contract = require("truffle-contract");
     
    import myContractArtifact from '../contracts/MyContract.sol';
    const MyContract = contract(myContractArtifact);
     
    MyContract.setProvider(provider);

    You can see this plugin in operation in the Truffle+Webpack Demo App. The demo is for Truffle 4.0 & Webpack 4.

    This package will re-run migration scripts whenever solidity files are modified. If you have multiple solidity files, the entire project will be redeployed.

    Installation

    $ npm install --save-dev truffle-solidity-loader

    Add the appropriate config to your loaders section of your Webpack 4 config:

    {
      test: /\.sol/,
      use: [
        {
          loader: 'json-loader'
        },
        {
          loader: 'truffle-solidity-loader',
          options: {
            network: 'ganache',
          }
        }
      ]
    }

    Webpack applies loaders right to left, therefore the output of truffle-solidity-loader goes into json-loader.

    truffle-config.js integration

    The loader will auto detect a truffle-config.js (or truffle.js) config file in your project and use that for configuration.

    Loader options

    • migrations_directory: The path truffle migration scripts
    • network: A network name to use
    • contracts_build_directory: path to directory of truffle JSON artifacts
    {
      test: /\.sol/,
      use: [
        {
          loader: 'json-loader'
        },
        {
          loader: 'truffle-solidity-loader',
          options: {
            network: 'ganache',
            migrations_directory: path.resolve(__dirname, './migrations'),
            contracts_build_directory: path.resolve(__dirname, './build/contracts')
          }
        }
      ]
    }

    Contributing

    • Open an issue to report bugs or provide feedback.
    • Submit PRs.
    • Respect the project coding style: StandardJS.

    js-standard-style

    License

    MIT

    Keywords

    none

    Install

    npm i truffle-solidity-loader

    DownloadsWeekly Downloads

    99

    Version

    0.1.32

    License

    MIT

    Unpacked Size

    9.97 kB

    Total Files

    8

    Last publish

    Collaborators

    • kevinbluer
    • tenthirtyone
    • lsqproduction
    • kevinweaver
    • leeftk
    • gnidan
    • davidmurdoch
    • eggplantzzz
    • fainashalts
    • haltman
    • rkalis
    • cds-amal
    • micaiahreid
    • johnmcdowall