raw loader for templates

pull/2368/head
Aniket-Engg 3 years ago committed by yann300
parent f6c447ff8d
commit 10a4c792ec
  1. 9
      apps/remix-ide/webpack.config.js
  2. 5
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  3. 2
      libs/remix-ws-templates/src/templates/blank/index.ts
  4. 10
      libs/remix-ws-templates/src/templates/erc20/index.ts
  5. 35
      libs/remix-ws-templates/src/templates/remixDefault/index.ts

@ -15,15 +15,6 @@ fs.writeFileSync('./apps/remix-ide/src/assets/version.json', JSON.stringify(vers
module.exports = config => {
const nxWebpackConfig = nxWebpack(config)
nxWebpackConfig.module.rules.push({ test: /\.txt$/, use: 'raw-loader' })
nxWebpackConfig.module.rules.push({ test: /\.sol$/, use: 'raw-loader' })
nxWebpackConfig.module.rules.push({ test: /\.test\.js$/, use: 'raw-loader' })
nxWebpackConfig.module.rules.push({ test: /\web3.ts$/, use: 'raw-loader' })
nxWebpackConfig.module.rules.push({ test: /\ethers.ts$/, use: 'raw-loader' })
const webpackConfig = {
...nxWebpackConfig,
node: {

@ -152,17 +152,12 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
default:
try {
console.log('templateWithContent--->', templateWithContent)
const templateList = Object.keys(templateWithContent)
if (!templateList.includes(template)) break
console.log('templateWithContent--->', templateWithContent[template])
// @ts-ignore
const files = await templateWithContent[template]()
console.log('files--->', files)
for (const file in files) {
try {
// const f2 = await import(files[file])
// console.log('files-with await f2-->', f2)
await workspaceProvider.set(file, files[file])
} catch (error) {
console.error(error)

@ -1 +1 @@
export default {}
export default async () => { return {}}

@ -1,17 +1,15 @@
export default async () => {
// @ts-ignore
console.log('------>', await import('raw-loader!./contracts/SampleERC20.sol'))
return {
// @ts-ignore
'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.sol')).default,
// @ts-ignore
'scripts/deploy_with_ethers.ts': (await import('raw-loader!./scripts/deploy_with_ethers.ts')).default,
'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default,
// @ts-ignore
'scripts/deploy_with_web3.ts': (await import('raw-loader!./scripts/deploy_with_web3.ts')).default,
'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default,
// @ts-ignore
'scripts/ethers.ts': (await import('raw-loader!./scripts/ethers.ts')).default,
'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default,
// @ts-ignore
'scripts/web3.ts': (await import('raw-loader!./scripts/web3.ts')).default,
'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default,
// @ts-ignore
'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default
}

@ -1,13 +1,24 @@
export default {
'contracts/1_Storage.sol': require('./contracts/1_Storage.sol').default,
'contracts/2_Owner.sol': require('./contracts/2_Owner.sol').default,
'contracts/3_Ballot.sol': require('./contracts/3_Ballot.sol').default,
'scripts/deploy_with_ethers.ts': require('./scripts/deploy_with_ethers.ts').default,
'scripts/deploy_with_web3.ts': require('./scripts/deploy_with_web3.ts').default,
'scripts/ethers.ts': require('./scripts/ethers.ts').default,
'scripts/web3.ts': require('./scripts/web3.ts').default,
'tests/Ballot_test.sol': require('./tests/Ballot_test.sol').default,
'tests/storage.test.js': require('./tests/storage.test.js').default,
'README.txt': require('./README.txt').default,
export default async () => {
return {
// @ts-ignore
'contracts/1_Storage.sol': (await import('raw-loader!./contracts/1_Storage.sol')).default,
// @ts-ignore
'contracts/2_Owner.sol': (await import('raw-loader!./contracts/2_Owner.sol')).default,
// @ts-ignore
'contracts/3_Ballot.sol': (await import('raw-loader!./contracts/3_Ballot.sol')).default,
// @ts-ignore
'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default,
// @ts-ignore
'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default,
// @ts-ignore
'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default,
// @ts-ignore
'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default,
// @ts-ignore
'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default,
// @ts-ignore
'tests/storage.test.js': (await import('!!raw-loader!./tests/storage.test.js')).default,
// @ts-ignore
'README.txt': (await import('raw-loader!./README.txt')).default,
}
}
Loading…
Cancel
Save