improve builds and local development

This commit is contained in:
Shawn Erquhart 2018-07-23 12:30:15 -04:00
parent aac5167461
commit ef90fb9925
22 changed files with 228 additions and 795 deletions

View File

@ -31,23 +31,19 @@ module.exports = {
'@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from', '@babel/plugin-proposal-export-default-from',
['inline-svg', {
svgo: {
plugins: [
{removeViewBox: false},
],
},
}],
], ],
env: { env: {
production: { production: {
plugins: [ plugins: [
['emotion', {hoist: true}], ['emotion', { hoist: true }],
], ],
}, },
development: { development: {
plugins: [ plugins: [
['emotion', {sourceMap: true, autoLabel: true}], ['emotion', {
sourceMap: true,
autoLabel: true,
}],
], ],
}, },
}, },

View File

@ -60,15 +60,16 @@
"last 2 ChromeAndroid versions" "last 2 ChromeAndroid versions"
], ],
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.54", "@babel/plugin-proposal-class-properties": "^7.0.0-beta.54",
"@babel/plugin-proposal-export-default-from": "^7.0.0-beta.54", "@babel/plugin-proposal-export-default-from": "^7.0.0-beta.54",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.54", "@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.54",
"@babel/preset-env": "^7.0.0-beta.54", "@babel/preset-env": "^7.0.0-beta.54",
"@babel/preset-react": "^7.0.0-beta.54", "@babel/preset-react": "^7.0.0-beta.54",
"all-contributors-cli": "^4.4.0", "all-contributors-cli": "^4.4.0",
"babel-loader": "^8.0.0-beta",
"babel-plugin-emotion": "^9.2.4", "babel-plugin-emotion": "^9.2.4",
"babel-plugin-inline-import": "^3.0.0",
"babel-plugin-inline-svg": "^1.0.0",
"babel-plugin-lodash": "^3.3.4", "babel-plugin-lodash": "^3.3.4",
"babel-plugin-module-resolver": "^3.0.0", "babel-plugin-module-resolver": "^3.0.0",
"babel-plugin-transform-builtin-extend": "^1.1.2", "babel-plugin-transform-builtin-extend": "^1.1.2",
@ -78,22 +79,18 @@
"deep-equal": "^1.0.1", "deep-equal": "^1.0.1",
"enzyme": "^3.1.0", "enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2", "enzyme-adapter-react-16": "^1.0.2",
"friendly-errors-webpack-plugin": "^1.7.0",
"jest": "^22.0.0", "jest": "^22.0.0",
"jest-cli": "^22.0.0", "jest-cli": "^22.0.0",
"lerna": "^2.11.0", "lerna": "^2.11.0",
"postcss-cssnext": "^3.0.2",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.1.3",
"raf": "^3.4.0", "raf": "^3.4.0",
"react-test-renderer": "^16.0.0", "react-test-renderer": "^16.0.0",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"rollup-plugin-babel": "^3.0.7" "style-loader": "^0.21.0",
"svg-inline-loader": "^0.8.0"
}, },
"workspaces": [ "workspaces": [
"packages/*" "packages/*"
], ],
"private": true, "private": true
"dependencies": {
"friendly-errors-webpack-plugin": "^1.7.0"
}
} }

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -13,18 +13,13 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"dependencies": { "dependencies": {
"js-base64": "^2.4.8", "js-base64": "^2.4.8",
"semaphore": "^1.1.0" "semaphore": "^1.1.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -13,18 +13,13 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"dependencies": { "dependencies": {
"js-base64": "^2.4.8", "js-base64": "^2.4.8",
"semaphore": "^1.1.0" "semaphore": "^1.1.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -12,17 +12,12 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"dependencies": { "dependencies": {
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -15,8 +15,8 @@
"dist/" "dist/"
], ],
"scripts": { "scripts": {
"watch": "cross-env NETLIFY_CMS_VERSION=$npm_package_version webpack-dev-server --hot --open", "watch": "webpack-dev-server --hot --open",
"build": "cross-env NETLIFY_CMS_VERSION=$npm_package_version webpack" "build": "webpack"
}, },
"keywords": [ "keywords": [
"netlify", "netlify",
@ -42,7 +42,7 @@
"jwt-decode": "^2.1.0", "jwt-decode": "^2.1.0",
"lib": "^3.0.2", "lib": "^3.0.2",
"localforage": "^1.4.2", "localforage": "^1.4.2",
"lodash": "^4.13.1", "lodash": "^4.17.10",
"mdast-util-definitions": "^1.2.2", "mdast-util-definitions": "^1.2.2",
"mdast-util-to-string": "^1.0.4", "mdast-util-to-string": "^1.0.4",
"moment": "^2.11.2", "moment": "^2.11.2",
@ -104,11 +104,11 @@
"what-input": "^5.0.3" "what-input": "^5.0.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0-beta.54", "css-loader": "^1.0.0",
"babel-loader": "^8.0.0-beta", "friendly-errors-webpack-plugin": "^1.7.0",
"cross-env": "^5.2.0", "to-string-loader": "^1.1.5",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0", "webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.4" "webpack-dev-server": "^3.1.5"
} }
} }

View File

@ -1,10 +1,12 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { css, injectGlobal, cx } from 'react-emotion'; import { css, injectGlobal, cx } from 'react-emotion';
//import 'redux-notifications/lib/styles.css'; // Import default redux-notifications styles into global scope. import reduxNotificationsStyles from 'redux-notifications/lib/styles.css';
import { shadows, colors, lengths } from 'netlify-cms-ui-default'; import { shadows, colors, lengths } from 'netlify-cms-ui-default';
injectGlobal` injectGlobal`
${reduxNotificationsStyles};
.notif__container { .notif__container {
z-index: 10000; z-index: 10000;
} }

View File

@ -7,8 +7,14 @@ module.exports = {
context: path.join(__dirname, 'src'), context: path.join(__dirname, 'src'),
entry: './index.js', entry: './index.js',
module: { module: {
noParse: /\.css$/, rules: [
...baseConfig.module, ...baseConfig.module.rules,
{
test: /\.css$/,
include: [/redux-notifications/],
use: ['to-string-loader', 'css-loader'],
},
],
}, },
devServer: { devServer: {
contentBase: './example', contentBase: './example',
@ -18,6 +24,7 @@ module.exports = {
port: 8080, port: 8080,
}, },
plugins: [ plugins: [
...baseConfig.plugins.filter(plugin => !plugin instanceof FriendlyErrorsWebpackPlugin),
new FriendlyErrorsWebpackPlugin({ new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: { compilationSuccessInfo: {
messages: ['Netlify CMS is now running at http://localhost:8080'], messages: ['Netlify CMS is now running at http://localhost:8080'],

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -13,14 +13,9 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -14,17 +14,12 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"dependencies": { "dependencies": {
"uuid": "^3.1.0" "uuid": "^3.1.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -10,17 +10,12 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"dependencies": { "dependencies": {
"localforage": "^1.4.2" "localforage": "^1.4.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,3 +0,0 @@
const config = require('../../babel.config.js');
module.exports = config;

View File

@ -10,7 +10,7 @@
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"watch": "webpack -w", "watch": "webpack -w",
"build": "cross-env NODE_ENV=production webpack" "build": "webpack"
}, },
"dependencies": { "dependencies": {
"react-aria-menubutton": "^5.1.0", "react-aria-menubutton": "^5.1.0",
@ -18,11 +18,6 @@
"react-transition-group": "^2.2.1" "react-transition-group": "^2.2.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0-beta.54",
"@babel/core": "^7.0.0-beta.54",
"cross-env": "^5.2.0",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.0-beta.7",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"
}, },

View File

@ -1,10 +1,51 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const webpack = require('webpack');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const pkg = require(path.join(process.cwd(), 'package.json')); const pkg = require(path.join(process.cwd(), 'package.json'));
const isProduction = process.env.NODE_ENV === 'production';
const plugins = () => {
const defaultPlugins = [
new FriendlyErrorsWebpackPlugin(),
];
if (isProduction) {
return [
...defaultPlugins,
new webpack.SourceMapDevToolPlugin({
filename: '[file].map',
moduleFilenameTemplate: info => path.posix.normalize(`../src/${info.resourcePath}`),
noSources: true,
}),
];
}
return [
...defaultPlugins,
];
};
const stats = () => {
if (isProduction) {
return {
builtAt: false,
colors: true,
entrypoints: false,
hash: false,
modules: false,
timings: false,
version: false,
};
}
return {
all: false,
};
};
module.exports = { module.exports = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', mode: isProduction ? 'production' : 'development',
entry: './src/index.js', entry: './src/index.js',
output: { output: {
path: process.cwd(), path: process.cwd(),
@ -17,22 +58,31 @@ module.exports = {
rules: [ rules: [
{ {
test: /\.js$/, test: /\.js$/,
use: 'babel-loader', use: {
loader: 'babel-loader',
options: {
configFile: path.join(__dirname, 'babel.config.js'),
},
},
exclude: /node_modules/, exclude: /node_modules/,
}, },
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
exclude: [/node_modules/],
loader: 'svg-inline-loader',
},
], ],
}, },
plugins: [ plugins: plugins(),
new FriendlyErrorsWebpackPlugin(), devtool: !isProduction && 'source-map',
],
devtool: 'source-map',
target: 'web', target: 'web',
/**
* Exclude peer dependencies from package bundles.
*/
externals: (context, request, cb) => { externals: (context, request, cb) => {
const peerDeps = Object.keys(pkg.peerDependencies || {}); const peerDeps = Object.keys(pkg.peerDependencies || {});
const isPeerDep = dep => new RegExp(`^${dep}($|/)`).test(request); const isPeerDep = dep => new RegExp(`^${dep}($|/)`).test(request);
return peerDeps.some(isPeerDep) ? cb(null, request) : cb(); return peerDeps.some(isPeerDep) ? cb(null, request) : cb();
}, },
stats: { stats: stats(),
all: false,
},
}; };

822
yarn.lock

File diff suppressed because it is too large Load Diff