Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Using require instead of import? #111

Open
burzum opened this issue Jan 22, 2018 · 1 comment
Open

Using require instead of import? #111

burzum opened this issue Jan 22, 2018 · 1 comment

Comments

@burzum
Copy link

burzum commented Jan 22, 2018

All the examples show the usage of import but I can't manage to get the damn config files to go through babel or whatever is necessary and already wasted hours on this.

So how do I do the same using require() or what do I need to do to get webpack3 to work with babel and import?

@ethyde
Copy link

ethyde commented May 26, 2018

Hello,

I have found 2 solutions :
With require

// in webpack.config.js
const { Config, environment } = require('webpack-config')

environment.setAll({
  env: () => process.env.NODE_ENV
})

module.exports = new Config().extend('config/webpack.[env].config.js')

for webpack.base.config

// webpack.base.config.js
const webpack = require('webpack')
const { Config } = require('webpack-config')


module.exports = new Config().merge({
  context: path.resolve(__dirname, '../app'),
  // base config
})

and for other webpack.[env].config

const { Config } = require('webpack-config')

module.exports = new Config().extend('config/webpack.base.config.js').merge({
  // config
})

Or you can rename webpack.config.js to webpack.config.babel.js and add babel-register. But babel-register add some
Webpack use interpret to make this work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants