Use NODE_ENV when building client bundles
This commit is contained in:
parent
bb0b62943f
commit
78c9de2e0e
|
@ -5,15 +5,11 @@ import entryManifest from 'entry-manifest';
|
||||||
import { createElement, createScript } from './markup.js';
|
import { createElement, createScript } from './markup.js';
|
||||||
|
|
||||||
function getEntryPoint(name, format) {
|
function getEntryPoint(name, format) {
|
||||||
let entryPoints;
|
for (let manifest of entryManifest) {
|
||||||
entryManifest.forEach(manifest => {
|
let bundles = manifest[name];
|
||||||
if (name in manifest) {
|
if (bundles) {
|
||||||
entryPoints = manifest[name];
|
return bundles.find(b => b.format === format);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (entryPoints) {
|
|
||||||
return entryPoints.find(e => e.format === format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -37,6 +33,8 @@ export default function getScripts(entryName, format, globalURLs) {
|
||||||
if (!entryPoint) return [];
|
if (!entryPoint) return [];
|
||||||
|
|
||||||
return getGlobalScripts(entryPoint, globalURLs).concat(
|
return getGlobalScripts(entryPoint, globalURLs).concat(
|
||||||
|
// Inline the code for this entry point into the page
|
||||||
|
// itself instead of using another <script> tag
|
||||||
createScript(entryPoint.code)
|
createScript(entryPoint.code)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ const url = require('rollup-plugin-url');
|
||||||
const entryManifest = require('./plugins/entryManifest');
|
const entryManifest = require('./plugins/entryManifest');
|
||||||
const pkg = require('./package.json');
|
const pkg = require('./package.json');
|
||||||
|
|
||||||
const env = process.env.BUILD_ENV || 'development';
|
|
||||||
|
|
||||||
const manifest = entryManifest();
|
const manifest = entryManifest();
|
||||||
|
|
||||||
const client = ['browse', 'main'].map(entryName => {
|
const client = ['browse', 'main'].map(entryName => {
|
||||||
|
@ -47,20 +45,20 @@ const client = ['browse', 'main'].map(entryName => {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
replace({
|
replace({
|
||||||
'process.env.NODE_ENV': JSON.stringify(env)
|
'process.env.NODE_ENV': JSON.stringify(
|
||||||
|
process.env.NODE_ENV || 'development'
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
url({
|
url({
|
||||||
limit: 5 * 1024,
|
limit: 5 * 1024,
|
||||||
publicPath: '/_client/'
|
publicPath: '/_client/'
|
||||||
}),
|
}),
|
||||||
compiler(
|
compiler()
|
||||||
env !== 'production' ? { formatting: 'PRETTY_PRINT' } : undefined
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const dependencies = (env === 'development'
|
const dependencies = (process.env.NODE_ENV === 'development'
|
||||||
? Object.keys(pkg.dependencies).concat(Object.keys(pkg.devDependencies || {}))
|
? Object.keys(pkg.dependencies).concat(Object.keys(pkg.devDependencies || {}))
|
||||||
: Object.keys(pkg.dependencies)
|
: Object.keys(pkg.dependencies)
|
||||||
).concat('react-dom/server');
|
).concat('react-dom/server');
|
||||||
|
|
Loading…
Reference in New Issue