Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  91] [ 2]  / answers: 1 / hits: 17251  / 9 Years ago, mon, july 6, 2015, 12:00:00

I'm writing an isomorphic Key Value Store with webpack.



This is currently my approach to load the libraries, which obviously doesn't work, because webpack wants to resolve both require.
Whats' the right approach?



var db = null;

if (typeof window === 'undefined') {
// node context
db = require('level');
} else {
// browser context
db = require('gazel');
}


I know, that you can provide a target to webpack.
But I have no idea how to use that.



Thanks!


More From » webpack

 Answers
7

I think resolve.alias would work for you. You would set db module to point at level or gazel depending on which build you are creating.


[#65909] Friday, July 3, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breap

Total Points: 606
Total Questions: 96
Total Answers: 108

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
breap questions
Thu, Jun 24, 21, 00:00, 3 Years ago
Wed, Mar 18, 20, 00:00, 4 Years ago
Mon, Oct 7, 19, 00:00, 5 Years ago
;