Skip to content

Commit c58dd0e

Browse files
committed
libraryTarget set to commonjs2
1 parent 4bcf27c commit c58dd0e

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "build/index.js",
66
"scripts": {
77
"start": "webpack-dev-server",
8-
"build": "webpack -p --display-modules",
8+
"build": "NODE_ENV=production webpack -p --display-modules",
99
"prepublishOnly": "npm run build"
1010
},
1111
"keywords": ["graphs", "react graphs", "branched react graphs"],

source/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
3-
import Graph from './Graph'
3+
import Graph from '../build/index'
44

55
ReactDOM.render(<Graph
66
vertices={[

webpack.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ const path = require('path')
22

33
const source = path.resolve(__dirname, 'source')
44
const build = path.resolve(__dirname, 'build')
5+
const production = process.env.NODE_ENV === 'production'
56

67
module.exports = {
7-
entry: path.join(source, 'Graph.js'),
8+
entry: path.join(source, production ? 'Graph.js' : 'index.js'),
89
output: {
910
path: build,
1011
filename: 'index.js',
11-
publicPath: '/'
12+
publicPath: '/',
13+
libraryTarget: production ? 'commonjs2': undefined
1214
},
1315
mode: process.env.NODE_ENV || 'development',
1416
devServer: {

0 commit comments

Comments
 (0)