How do I include truffle.js when using the truffle-solidity-loader and webpack?

214 views Asked by At

I have a simple project that is just using webpack to compile a Solidity contract using the truffle loader. I wire everything up and try to run it and get...

ERROR in ./src/test.sol
Module build failed (from ./node_modules/truffle-solidity-loader/index.js):
ValidationError: truffle-solidity-loader Invalid Options

options should have required property 'network'

I have tried putting the truffle js in multiple places...

  • The source root (imported by index.js)
  • The project root (as is in the example here)
  • In the webpack root (in my case ./webpack)

None of these seem to be working and they all produce the same error. I have tried using both truffle.js files...

module.exports = {
  rpc: {
    host: 'localhost',
    port: 8545,
    gas: 1900000
  },
  migrations_directory: './migrations'
}

and

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};

How do I wire in the truffle.js when using the webpack loader?

Update

I also tried the following...

import truffleConfig from '../truffle.js'
import mortal from "./test.sol"
import Web3 from 'web3';

const provider = new Web3.providers.HttpProvider('http://localhost:8545')
mortal.setProvider(provider);

But I am still getting the same issue.

0

There are 0 answers