Commit ca16f6cd by Ari Rizzitano

cleanup

parent 40487a5f
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
"author": "arizzitano", "author": "arizzitano",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "webpack", "build": "NODE_ENV=production webpack",
"build-docs": "install-self-peers && webpack --config ./webpack.docs.config.js", "build-docs": "NODE_ENV=docs && install-self-peers && webpack",
"lint": "eslint .", "lint": "eslint .",
"prestart": "install-self-peers", "prestart": "install-self-peers",
"poststop": "yarn install", "poststop": "yarn install",
"start": "BABEL_ENV=webpack webpack-dev-server --config ./webpack.dev.config.js --watch" "start": "BABEL_ENV=webpack webpack-dev-server --watch"
}, },
"dependencies": { "dependencies": {
"classnames": "^2.2.5", "classnames": "^2.2.5",
......
import React, { Component } from 'react';
export default class Button extends React.Component {
render() {
return (
<button>hello i'm a button</button>
);
}
}
let lastId = 0; let lastId = 0;
export const newId = (prefix='id') => { export const newId = (prefix = 'id') => {
lastId++; lastId += 1;
return `${prefix}${lastId}`; return `${prefix}${lastId}`;
}; };
const path = require('path'); const path = require('path');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
module.exports = { const env = process.env.NODE_ENV || 'dev';
const base = {
devtool: 'source-map', devtool: 'source-map',
entry: path.resolve('./src/index.js'), entry: {
main: path.resolve('./docs/App.js'),
},
output: { output: {
path: path.resolve('./dist'), filename: 'bundle.js',
filename: 'excalibur.min.js', path: path.resolve('./docs'),
library: 'excalibur',
libraryTarget: 'umd', libraryTarget: 'umd',
}, },
externals: [{
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
{
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
},
},
{
'react-addons-transition-group': {
commonjs: 'react-addons-transition-group',
commonjs2: 'react-addons-transition-group',
amd: 'react-addons-transition-group',
root: ['React', 'addons', 'TransitionGroup'],
},
},
{
'react-addons-css-transition-group': {
commonjs: 'react-addons-css-transition-group',
commonjs2: 'react-addons-css-transition-group',
amd: 'react-addons-css-transition-group',
root: ['React', 'addons', 'CSSTransitionGroup'],
},
}],
module: { module: {
rules: [ rules: [
{ {
...@@ -54,8 +26,103 @@ module.exports = { ...@@ -54,8 +26,103 @@ module.exports = {
}, },
}, },
{ loader: 'source-map-loader' }, { loader: 'source-map-loader' },
] ],
}, },
], ],
}, },
}; };
const additionalConfig = {
// dev runs the doc site locally.
dev: {
devServer: {
contentBase: path.resolve('./docs'),
historyApiFallback: true,
stats: {
chunks: false,
},
},
node: {
fs: 'empty',
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [
'babel-loader?cacheDirectory',
],
},
],
},
},
// docs builds the doc site for production.
docs: {
plugins: [
new StaticSiteGeneratorPlugin('main', [
'/',
'/header/',
'/inputs/',
], {}),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
},
},
},
],
},
},
// production builds the library for external consumption
production: {
entry: path.resolve('./src/index.js'),
output: {
path: path.resolve('./dist'),
filename: 'excalibur.min.js',
library: 'excalibur',
libraryTarget: 'umd',
},
externals: [{
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
{
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
},
},
{
'react-addons-transition-group': {
commonjs: 'react-addons-transition-group',
commonjs2: 'react-addons-transition-group',
amd: 'react-addons-transition-group',
root: ['React', 'addons', 'TransitionGroup'],
},
},
{
'react-addons-css-transition-group': {
commonjs: 'react-addons-css-transition-group',
commonjs2: 'react-addons-css-transition-group',
amd: 'react-addons-css-transition-group',
root: ['React', 'addons', 'CSSTransitionGroup'],
},
}],
},
};
module.exports = Object.assign(base, additionalConfig[env]);
const path = require('path');
module.exports = {
devtool: 'source-map',
devServer: {
contentBase: path.resolve('./docs'),
historyApiFallback: true,
stats: {
chunks: false
}
},
entry: {
main: './docs/App.js'
},
node: {
fs: 'empty'
},
output: {
filename: 'bundle.js',
path: path.resolve('./docs'),
libraryTarget: 'umd'
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [
'babel-loader?cacheDirectory',
],
},
],
},
};
const path = require('path');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
module.exports = {
entry: {
main: path.resolve('./docs/App.js'),
},
output: {
path: path.resolve('./docs'),
filename: 'bundle.js',
libraryTarget: 'umd',
},
plugins: [
new StaticSiteGeneratorPlugin('main', [
'/',
'/header/',
'/inputs/',
], {}),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
},
},
},
],
},
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment