1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-19 12:51:59 +02:00

update webpack and rollup configs

This commit is contained in:
Ian Storm Taylor 2018-02-21 17:48:08 -08:00
parent 1fbf999c41
commit bc524bd43a
6 changed files with 45 additions and 54 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# Build files.
*.js.map
build/
dist/
lib/

View File

@ -89,17 +89,17 @@
"benchmark": "mkdir -p ./tmp && cross-env BABEL_ENV=test babel-node ./node_modules/.bin/_matcha --reporter ./support/benchmark/reporter ./packages/*/benchmark/index.js > ./tmp/benchmark-comparison.json && cross-env BABEL_ENV=test babel-node ./support/benchmark/compare",
"benchmark:save": "mkdir -p ./tmp && cross-env BABEL_ENV=test babel-node ./node_modules/.bin/_matcha --reporter ./support/benchmark/reporter ./packages/*/benchmark/index.js > ./tmp/benchmark-baseline.json",
"bootstrap": "lerna bootstrap && yarn build",
"build": "rollup --config",
"build:gh": "cross-env NODE_ENV=production rollup --config && cross-env NODE_ENV=production webpack --config support/webpack.config.js",
"build": "rollup --config ./support/rollup/config.js",
"build:gh-pages": "cross-env NODE_ENV=production rollup --config ./support/rollup/config.js && cross-env NODE_ENV=production webpack --config support/webpack/config.js",
"clean": "lerna run clean && rm -rf ./node_modules ./dist ./examples/dist",
"gh-pages": "yarn build:gh && gh-pages --dist ./examples/dist",
"gh-pages": "yarn build:gh-pages && gh-pages --dist ./examples/dist",
"lint": "eslint packages/*/src packages/*/test examples/*/*.js examples/dev/*/*.js && prettier --list-different '**/*.{js,jsx,md,json,css}'",
"open": "open http://localhost:8080",
"prettier": "prettier --write '**/*.{js,jsx,md,json,css}'",
"release": "yarn test && yarn lint && lerna publish && yarn gh-pages",
"server": "webpack-dev-server --config support/webpack.config.js",
"server": "webpack-dev-server --config ./support/webpack/config.js",
"start": "npm-run-all --parallel --print-label watch server",
"test": "cross-env BABEL_ENV=test mocha --require babel-core/register ./packages/*/test/index.js",
"watch": "rollup --config --watch"
"watch": "rollup --config ./support/rollup/config.js --watch"
}
}

View File

@ -1,26 +0,0 @@
import factory from './support/rollup/packages'
import slate from './packages/slate/package.json'
import slateBase64Serializer from './packages/slate-base64-serializer/package.json'
import slateDevLogger from './packages/slate-dev-logger/package.json'
import slateHtmlSerializer from './packages/slate-html-serializer/package.json'
import slateHyperscript from './packages/slate-hyperscript/package.json'
import slatePlainSerializer from './packages/slate-plain-serializer/package.json'
import slatePropTypes from './packages/slate-prop-types/package.json'
import slateReact from './packages/slate-react/package.json'
import slateSchemaViolations from './packages/slate-schema-violations/package.json'
import slateSimulator from './packages/slate-simulator/package.json'
const configurations = [
...factory(slate),
...factory(slateBase64Serializer),
...factory(slateDevLogger),
...factory(slateHtmlSerializer),
...factory(slateHyperscript),
...factory(slatePlainSerializer),
...factory(slatePropTypes),
...factory(slateReact),
...factory(slateSchemaViolations),
...factory(slateSimulator),
]
export default configurations

26
support/rollup/config.js Normal file
View File

@ -0,0 +1,26 @@
import factory from './factory'
import slate from '../../packages/slate/package.json'
import slateBase64Serializer from '../../packages/slate-base64-serializer/package.json'
import slateDevLogger from '../../packages/slate-dev-logger/package.json'
import slateHtmlSerializer from '../../packages/slate-html-serializer/package.json'
import slateHyperscript from '../../packages/slate-hyperscript/package.json'
import slatePlainSerializer from '../../packages/slate-plain-serializer/package.json'
import slatePropTypes from '../../packages/slate-prop-types/package.json'
import slateReact from '../../packages/slate-react/package.json'
import slateSchemaViolations from '../../packages/slate-schema-violations/package.json'
import slateSimulator from '../../packages/slate-simulator/package.json'
const configurations = [
...factory(slate),
...factory(slateBase64Serializer),
...factory(slateDevLogger),
...factory(slateHtmlSerializer),
...factory(slateHyperscript),
...factory(slatePlainSerializer),
...factory(slatePropTypes),
...factory(slateReact),
...factory(slateSchemaViolations),
...factory(slateSimulator),
]
export default configurations

View File

@ -5,22 +5,24 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackTemplate = require('html-webpack-template')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const NamedModulesPlugin = webpack.NamedModulesPlugin
const HotModuleReplacementPlugin = webpack.HotModuleReplacementPlugin
const IS_PROD = process.env.NODE_ENV === 'production'
const IS_DEV = !IS_PROD
const config = {
entry: ['react-hot-loader/patch', './examples/index.js'],
output: {
path: path.resolve(__dirname, 'examples/dist'),
filename: '[name].[hash].js',
path: path.resolve(__dirname, '../../build'),
filename: '[name]-[hash].js',
},
devtool: IS_PROD ? 'source-map' : 'inline-source-map',
devServer: {
contentBase: './examples',
publicPath: '/',
hot: true,
},
module: {
rules: [
{
@ -49,7 +51,6 @@ const config = {
},
],
},
plugins: [
new ExtractTextPlugin('[name]-[contenthash].css'),
new HtmlWebpackPlugin({
@ -61,22 +62,11 @@ const config = {
'https://fonts.googleapis.com/icon?family=Material+Icons',
],
}),
],
}
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new CleanWebpackPlugin(['examples/dist']),
new UglifyJSPlugin({ sourceMap: true }),
new CopyWebpackPlugin(['examples/CNAME'])
)
config.devtool = 'source-map'
} else {
config.plugins.push(
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
)
config.devtool = 'inline-source-map'
IS_PROD && new CleanWebpackPlugin([path.resolve(__dirname, '../../build')]),
IS_PROD && new CopyWebpackPlugin(['examples/CNAME']),
IS_DEV && new NamedModulesPlugin(),
IS_DEV && new HotModuleReplacementPlugin(),
].filter(Boolean),
}
module.exports = config