Skip to content

Commit

Permalink
fix(export): SDK is working in node again
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger authored and Khaledgarbaya committed Mar 30, 2017
1 parent 6ab3b61 commit 8ff6a00
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion karma.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use karma.conf.local.js for local tests
// Use karma.conf.saucelabs.js for saucelabs tests
var _ = require('lodash')
var webpackConfig = _.cloneDeep(require('./webpack.config.js'))
var webpackConfig = _.cloneDeep(require('./webpack.config.js')[0])
delete webpackConfig.entry
delete webpackConfig.output
webpackConfig.devtool = 'inline-source-map'
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"description": "Client for Contentful's Content Delivery API",
"version": "4.1.0",
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/",
"main": "./dist/contentful.js",
"main": "./dist/contentful.node.js",
"browser": "./dist/contentful.js",
"repository": {
"type": "git",
"url": "https://github.com/contentful/contentful.js.git"
Expand All @@ -15,8 +16,8 @@
"clean": "rimraf dist && rimraf coverage",
"build": "npm run clean && npm run build:ci",
"build:ci": "npm run vendor:version && npm run build:standalone",
"build:standalone": "BABEL_ENV=webpack webpack && BABEL_ENV=webpack webpack -p --output-filename contentful.min.js",
"build:standalone:log": "BABEL_ENV=webpack npm run build && webpack -p --json --profile --output-filename contentful.min.js > webpack-build-log.json",
"build:standalone": "BABEL_ENV=webpack webpack && BABEL_ENV=webpack NODE_ENV=production webpack -p",
"build:standalone:log": "BABEL_ENV=webpack npm run build && BABEL_ENV=webpack NODE_ENV=production webpack -p --json --profile > webpack-build-log.json",
"docs:build": "esdoc -c esdoc.json",
"docs:dev": "npm run build && npm run docs:build",
"docs:watch": "watchy -w lib npm run docs:dev",
Expand Down Expand Up @@ -47,7 +48,6 @@
},
"types": "./index.d.ts",
"files": [
"index.js",
"version.js",
"index.d.ts",
"dist",
Expand Down
57 changes: 38 additions & 19 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,42 @@ if (process.env.NODE_ENV === 'production') {
)
}

module.exports = {
context: path.join(__dirname, 'lib'),
entry: './contentful.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'contentful.js',
libraryTarget: 'umd',
library: 'contentful'
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components|dist)/,
loader: 'babel-loader'
}
]
const loaders = [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components|dist)/,
loader: 'babel-loader'
}
]

module.exports = [
{
context: path.join(__dirname, 'lib'),
entry: './contentful.js',
output: {
path: path.join(__dirname, 'dist'),
filename: `contentful${process.env.NODE_ENV === 'production' ? '.min' : ''}.js`,
libraryTarget: 'umd',
library: 'contentful'
},
module: {
loaders
},
plugins
},
plugins: plugins
}
{
context: path.join(__dirname, 'lib'),
entry: './contentful.js',
target: 'node',
output: {
path: path.join(__dirname, 'dist'),
filename: `contentful.node${process.env.NODE_ENV === 'production' ? '.min' : ''}.js`,
libraryTarget: 'commonjs2',
library: 'contentful'
},
module: {
loaders
},
plugins
}
]

0 comments on commit 8ff6a00

Please sign in to comment.