refactor(rollup): cleanup tasks
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
"start:examples": "rollup -c rollup.examples.js -w",
|
"start:examples": "rollup -c rollup.examples.js -w",
|
||||||
"build:examples": "rollup -c rollup.examples.js --environment NODE_ENV:production",
|
"build:examples": "rollup -c rollup.examples.js --environment NODE_ENV:production",
|
||||||
"dev": "npm run start:examples",
|
"dev": "npm run start:examples",
|
||||||
"start:testserver": "npm run build && rollup -c rollup.examples.js -w --environment NODE_ENV:testing",
|
"start:testserver": "rollup -c --environment NODE_ENV:testing && rollup -c rollup.examples.js -w --environment NODE_ENV:testing",
|
||||||
"build:dev": "npm install && npm run build:examples",
|
"build:dev": "npm install && npm run build:examples",
|
||||||
"dev:wait": "start-server-and-test start:testserver http-get://localhost:3000",
|
"dev:wait": "start-server-and-test start:testserver http-get://localhost:3000",
|
||||||
"test": "npm run dev:wait test:chrome",
|
"test": "npm run dev:wait test:chrome",
|
||||||
|
|||||||
+4
-3
@@ -10,9 +10,10 @@ import typescript from 'rollup-plugin-typescript2';
|
|||||||
import pkg from './package.json';
|
import pkg from './package.json';
|
||||||
|
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
const processEnv = isProd ? 'production' : 'development';
|
const isTesting = process.env.NODE_ENV === 'testing';
|
||||||
|
const processEnv = isProd || isTesting ? 'production' : 'development';
|
||||||
|
|
||||||
const baseConfig = ({ mainFile = pkg.main, moduleFile = pkg.module, injectCSS = true } = {}) => ({
|
export const baseConfig = ({ mainFile = pkg.main, moduleFile = pkg.module, injectCSS = true } = {}) => ({
|
||||||
input: 'src/index.ts',
|
input: 'src/index.ts',
|
||||||
external: ['react', 'react-dom', /@babel\/runtime/],
|
external: ['react', 'react-dom', /@babel\/runtime/],
|
||||||
onwarn(warning, rollupWarn) {
|
onwarn(warning, rollupWarn) {
|
||||||
@@ -61,7 +62,7 @@ const baseConfig = ({ mainFile = pkg.main, moduleFile = pkg.module, injectCSS =
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export default isProd
|
export default isProd && !isTesting
|
||||||
? [
|
? [
|
||||||
baseConfig(),
|
baseConfig(),
|
||||||
baseConfig({
|
baseConfig({
|
||||||
|
|||||||
+4
-4
@@ -8,7 +8,7 @@ import postcss from 'rollup-plugin-postcss';
|
|||||||
import livereload from 'rollup-plugin-livereload';
|
import livereload from 'rollup-plugin-livereload';
|
||||||
import serve from 'rollup-plugin-serve';
|
import serve from 'rollup-plugin-serve';
|
||||||
|
|
||||||
import libraryRollupConfig from './rollup.config.js';
|
import { baseConfig } from './rollup.config.js';
|
||||||
|
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
const isTesting = process.env.NODE_ENV === 'testing';
|
const isTesting = process.env.NODE_ENV === 'testing';
|
||||||
@@ -16,8 +16,8 @@ const isTesting = process.env.NODE_ENV === 'testing';
|
|||||||
const serveFiles = !isProd || isTesting;
|
const serveFiles = !isProd || isTesting;
|
||||||
const doLiveReload = !isProd && !isTesting;
|
const doLiveReload = !isProd && !isTesting;
|
||||||
|
|
||||||
const rollupConfig = {
|
const rollupExamplesConfig = {
|
||||||
input: ['example/src/index.js'],
|
input: 'example/src/index.js',
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
dir: 'example/public/dist',
|
dir: 'example/public/dist',
|
||||||
@@ -55,4 +55,4 @@ const rollupConfig = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default isTesting ? rollupConfig : [libraryRollupConfig, rollupConfig];
|
export default isTesting ? rollupExamplesConfig : [baseConfig(), rollupExamplesConfig];
|
||||||
|
|||||||
Reference in New Issue
Block a user