I have a npm package with two enviroments. Browser and Server. Is there a way to force webpack loading only a subobject of the package? This is my index.js:
module.exports = {
browser: require('./browser.js'),
server: require('./server.js')
};
When I try this on the browser: import { browser } from 'synko';
webpack is loading server too.
Is possible to have two environments in one npm package? Or I should use browserify?
I found the solution here: https://gist.github.com/defunctzombie/4339901#gistcomment-1582456
So in my case my package.json now have this:
"main": "./server.js",
"browser": "./browser.js",
And then I can import it like this: import synko from 'synko';
for the browser.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.