Add second config for library

This commit is contained in:
DD Liu 2017-07-14 11:29:12 -04:00
parent 0daa70fc7c
commit 414d4aa01a
8 changed files with 48 additions and 74383 deletions

4
.gitignore vendored
View file

@ -4,3 +4,7 @@
# NPM
/node_modules
npm-*
# Buid
playground/*
dist/*

View file

@ -2,10 +2,10 @@
"name": "scratch-blobs",
"version": "0.1.0",
"description": "Graphical User Interface for the Scratch 3.0 paint editor, which is used to make and edit sprites for use in projects.",
"main": "./src/index.js",
"main": "./dist/scratch-paint.js",
"scripts": {
"build": "npm run clean && webpack --progress --colors --bail",
"clean": "rimraf ./build && mkdirp build",
"clean": "rimraf ./dist && mkdirp dist && rimraf ./playground && mkdirp playground",
"deploy": "touch playground/.nojekyll && gh-pages -t -d playground -m \"Build for $(git log --pretty=format:%H -n1)\"",
"lint": "eslint . --ext .js,.jsx",
"start": "webpack-dev-server",
@ -38,6 +38,7 @@
"eslint-plugin-react": "^7.0.1",
"gh-pages": "github:rschamp/gh-pages#publish-branch-to-subfolder",
"html-webpack-plugin": "2.28.0",
"lodash.defaultsdeep": "4.6.0",
"minilog": "3.1.0",
"mkdirp": "^0.5.1",
"postcss-import": "^10.0.0",

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Scratch 3.0 Paint Editor</title>
</head>
<body>
<script type="text/javascript" src="lib.min.js"></script><script type="text/javascript" src="playground.js"></script></body>
</html>

22175
playground/lib.min.js vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,6 @@
var path = require('path');
var webpack = require('webpack');
const defaultsDeep = require('lodash.defaultsdeep');
const path = require('path');
const webpack = require('webpack');
// Plugins
var HtmlWebpackPlugin = require('html-webpack-plugin');
@ -9,21 +10,8 @@ var autoprefixer = require('autoprefixer');
var postcssVars = require('postcss-simple-vars');
var postcssImport = require('postcss-import');
module.exports = {
devServer: {
contentBase: path.resolve(__dirname, 'build'),
host: '0.0.0.0',
port: process.env.PORT || 8078
},
const base = {
devtool: 'cheap-module-source-map',
entry: {
lib: ['react', 'react-dom'],
playground: './src/playground/playground.jsx'
},
output: {
path: path.resolve(__dirname, 'playground'),
filename: '[name].js'
},
externals: {
React: 'react',
ReactDOM: 'react-dom'
@ -71,10 +59,6 @@ module.exports = {
new webpack.optimize.CommonsChunkPlugin({
name: 'lib',
filename: 'lib.min.js'
}),
new HtmlWebpackPlugin({
template: 'src/playground/index.ejs',
title: 'Scratch 3.0 Paint Editor'
})
].concat(process.env.NODE_ENV === 'production' ? [
new webpack.optimize.UglifyJsPlugin({
@ -83,3 +67,39 @@ module.exports = {
})
] : [])
};
module.exports = [
// For the playground
defaultsDeep({}, base, {
devServer: {
contentBase: path.resolve(__dirname, 'playground'),
host: '0.0.0.0',
port: process.env.PORT || 8078
},
entry: {
lib: ['react', 'react-dom'],
playground: './src/playground/playground.jsx'
},
output: {
path: path.resolve(__dirname, 'playground'),
filename: '[name].js'
},
plugins: base.plugins.concat([
new HtmlWebpackPlugin({
template: 'src/playground/index.ejs',
title: 'Scratch 3.0 Paint Editor Playground'
})
])
}),
// For use as a library
defaultsDeep({}, base, {
entry: {
'lib': ['react', 'react-dom'],
'scratch-paint': './src/index.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
}
})
];