0

I want to refactor a large requireJS project to use es6 import/export and webpack. In the requireJS requirejs.config call, I use the config section to pass some project specific settings to some views:

requirejs.config({
  baseUrl: 'js/cfe/app',
  paths: { },
  config: {
    'views/test/TestView': {
      isTest: true
    }
})

and in the view:

define(['module'], function(module) {
  var t = module.config().isTest
})

How can I accomplish the same behaviour in my webpack setup?

2
  • Have you configured webpack to compile your files using babel?
    – thitemple
    Commented Apr 11, 2016 at 0:40
  • Yes, that the plan Commented Apr 11, 2016 at 5:35

1 Answer 1

1

I'm not quite sure if I understand your question correctly, but maybe you can use my answer anyways.

I think you could extract your configuration object to JSON file, use a loader (RAW loader works fine) to include it in your bundle, and then when you need it simply use ES6 import:

import config from 'myconfig.json';

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.