Commit 18c3f5b5 authored by Dan Notestein's avatar Dan Notestein

Merge branch 'upgradeWebpack' into 'develop'

Upgrade webpack to v4, babel to v7, same as condenser MR

See merge request !77
parents c7253b35 16579618
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-runtime", "transform-decorators-legacy"],
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"@babel/plugin-transform-runtime",
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-modules-commonjs"
],
"compact": true
}
......@@ -26,3 +26,4 @@ services:
- ./src:/var/app/src:delegated
- ./webpack:/var/app/webpack:delegated
- ./config:/var/app/config:delegated
- ./node_modules:/var/app/node_modules:delegated
......@@ -10,7 +10,7 @@
"author": "Hive",
"main": "index.js",
"scripts": {
"build": "NODE_ENV=production webpack --config ./webpack/prod.config.js && rm -rf ./lib && babel src --out-dir lib -Dq",
"build": "NODE_ENV=production webpack --config ./webpack/prod.config.js && rm -rf ./lib && babel src --out-dir lib -D",
"checktranslations": "node scripts/check_translations.js",
"ci:eslint": "eslint src/",
"ci:test": "jest --coverage",
......@@ -41,10 +41,37 @@
"testURL": "http://localhost/"
},
"dependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.5",
"@hiveio/hive-js": "0.8.8",
"@steem/crypto-session": "git+https://github.com/steemit/crypto-session.git#83a90b319ce5bc6a70362d52a15a815de7e729bb",
"assert": "1.4.1",
"autoprefixer-loader": "3.2.0",
"autoprefixer": "^9.6.1",
"babel-eslint": "10.1.0",
"babel-loader": "^8.2.0",
"babel-plugin-react-intl": "2.3.1",
"babel-plugin-transform-inline-environment-variables": "0.2.0",
"bigi": "1.4.2",
"blocked": "1.2.1",
"blueimp-file-upload": "9.22.1",
......@@ -55,25 +82,21 @@
"cluster": "0.7.7",
"co-body": "5.1.1",
"config": "1.26.2",
"core-js": "^3.6.5",
"counterpart": "0.17.9",
"cpu-stat": "2.0.1",
"css-loader": "2.1.1",
"currency-symbol-map": "3.1.0",
"diff-match-patch": "1.0.0",
"disk-stat": "1.0.4",
"dsteem": "0.11.3",
"ecurve": "1.0.5",
"estraverse-fb": "1.3.2",
"file-loader": "0.11.2",
"foundation-sites": "git+https://github.com/steemit/foundation-sites.git#e8e32c715bbc4c822b80b555345f61337269ca78",
"git-rev-sync": "1.9.1",
"highcharts": "6.1.0",
"hivesigner": "3.2.1",
"humanize-number": "0.0.2",
"imports-loader": "0.7.1",
"intl": "1.2.5",
"iso": "5.2.0",
"json-loader": "0.5.7",
"koa": "1.4.1",
"koa-body": "1.6.0",
"koa-compressor": "1.0.3",
......@@ -93,6 +116,7 @@
"koa-static-cache": "4.1.1",
"lodash.debounce": "4.0.8",
"mem-stat": "1.0.5",
"mini-css-extract-plugin": "^1.2.1",
"minimist": "1.2.3",
"mixpanel": "0.5.0",
"moment": "2.24.0",
......@@ -102,7 +126,7 @@
"number-abbreviate": "2.0.0",
"os": "0.1.1",
"picturefill": "3.0.2",
"raw-loader": "0.5.1",
"postcss": "^8.1.6",
"react": "15.6.2",
"react-ab-test": "1.7.0",
"react-addons-pure-render-mixin": "15.4.2",
......@@ -130,7 +154,7 @@
"redux-saga": "0.16.0",
"remarkable": "1.7.1",
"sanitize-html": "1.14.1",
"sass-loader": "6.0.6",
"sass": "^1.29.0",
"secure-random": "1.1.1",
"sendgrid": "4.10.0",
"sequelize": "5.15.1",
......@@ -140,7 +164,6 @@
"statsd-client": "0.4.2",
"steemscript": "1.1.0",
"store": "1.3.20",
"style-loader": "0.18.2",
"svg-inline-loader": "0.8.0",
"svg-inline-react": "1.0.3",
"svgo-loader": "1.2.1",
......@@ -148,7 +171,6 @@
"uncontrollable": "3.3.1",
"underscore.string": "3.3.5",
"universal-cookie": "^4.0.4",
"url-loader": "0.6.2",
"web-push": "3.2.3",
"webpack-isomorphic-tools": "3.0.5",
"websocket": "1.0.24",
......@@ -156,19 +178,32 @@
"xmldom": "0.1.27"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "10.1.0",
"babel-jest": "22.0.6",
"babel-loader": "7.1.2",
"babel-plugin-react-intl": "2.3.1",
"babel-plugin-transform-decorators-legacy": "1.3.4",
"babel-plugin-transform-inline-environment-variables": "0.2.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"babel-preset-stage-0": "6.24.1",
"babel-loader": "^8.2.0",
"co-supertest": "0.0.10",
"css-loader": "5.0.1",
"dev-ip": "1.0.1",
"enzyme": "3.3.0",
"enzyme-adapter-react-15": "1.0.5",
......@@ -179,16 +214,20 @@
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"extract-text-webpack-plugin": "3.0.1",
"file-loader": "6.2.0",
"git-rev-sync": "1.9.1",
"husky": "0.14.3",
"jest": "22.0.6",
"imports-loader": "1.2.0",
"jest": "23",
"jsdom": "9.12.0",
"koa-webpack-dev-middleware": "1.4.6",
"koa-webpack-hot-middleware": "1.0.3",
"lint-staged": "6.0.0",
"mock-local-storage": "1.0.5",
"node-watch": "0.5.5",
"postcss-loader": "^4.0.4",
"prettier": "2.0.5",
"raw-loader": "4.0.2",
"react-addons-perf": "15.4.2",
"react-addons-test-utils": "15.4.2",
"react-test-renderer": "15.6.2",
......@@ -197,14 +236,21 @@
"redux-devtools-extension": "2.13.5",
"redux-mock-store": "1.5.1",
"regenerator-runtime": "0.11.1",
"sass-loader": "10.0.5",
"sinon": "1.17.7",
"style-loader": "2.0.0",
"supertest": "1.2.0",
"webpack": "3.7.1",
"webpack-bundle-analyzer": "3.3.2",
"url-loader": "4.1.1",
"webpack": "4.x.x",
"webpack-bundle-analyzer": "^4.1.0",
"webpack-cli": "^4.2.0",
"webpack-dev-middleware": "1.12.0"
},
"engines": {
"node": ">=8.7.0",
"npm": ">=5.4.2"
}
},
"browserslist": [
"defaults"
]
}
import 'babel-core/register';
import 'babel-polyfill';
import '@babel/register';
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import 'whatwg-fetch';
import store from 'store';
import { VIEW_MODE_WHISTLE, PARAM_VIEW_MODE } from 'shared/constants';
......
......@@ -11,14 +11,14 @@
.SignUp--reddit-button {
background-color: #ef4623;
&:hover {
background-color: scale-color(#ef4623, -6%);
background-color: scale-color(#ef4623, $lightness: -6%);
}
}
.SignUp--fb-button {
background-color: #3b5998;
&:hover {
background-color: scale-color(#3b5998, -6%);
background-color: scale-color(#3b5998, $lightness: -6%);
}
}
......
......@@ -7,7 +7,7 @@ import Remarkable from 'remarkable';
const remarkable = new Remarkable({ html: true, linkify: false });
const getValidImage = array => {
const getValidImage = (array) => {
return array &&
Array.isArray(array) &&
array.length >= 1 &&
......@@ -77,7 +77,9 @@ export default function extractContent(get, content) {
rtags = HtmlReady(htmlText, { mutate: false });
}
[image_link] = Array.from(rtags.images);
if (rtags.images) {
[image_link] = Array.from(rtags.images);
}
}
// Was causing broken thumnails. IPFS was not finding images uploaded to another server until a restart.
......
......@@ -79,7 +79,7 @@ const XMLSerializer = new xmldom.XMLSerializer();
If hideImages and mutate is set to true all images will be replaced
by <pre> elements containing just the image url.
*/
export default function(html, { mutate = true, hideImages = false } = {}) {
export default function (html, { mutate = true, hideImages = false } = {}) {
const state = { mutate };
state.hashtags = new Set();
state.usertags = new Set();
......@@ -123,7 +123,7 @@ export default function(html, { mutate = true, hideImages = false } = {}) {
function traverse(node, state, depth = 0) {
if (!node || !node.childNodes) return;
Array(...node.childNodes).forEach(child => {
Array.from(node.childNodes).forEach((child) => {
// console.log(depth, 'child.tag,data', child.tagName, child.data)
const tag = child.tagName ? child.tagName.toLowerCase() : null;
if (tag) state.htmltags.add(tag);
......@@ -150,10 +150,8 @@ function link(state, child) {
// Unlink potential phishing attempts
if (
(url.indexOf('#') !== 0 && // Allow in-page links
(child.textContent.match(/(www\.)?hive\.blog/i) &&
!url.match(
/https?:\/\/(.*@)?(www\.)?hive\.blog/i
))) ||
child.textContent.match(/(www\.)?hive\.blog/i) &&
!url.match(/https?:\/\/(.*@)?(www\.)?hive\.blog/i)) ||
Phishing.looksPhishy(url)
) {
const phishyDiv = child.ownerDocument.createElement('div');
......@@ -216,7 +214,7 @@ function img(state, child) {
// For all img elements with non-local URLs, prepend the proxy URL
function proxifyImages(doc) {
if (!doc) return;
[...doc.getElementsByTagName('img')].forEach(node => {
Array.from(doc.getElementsByTagName('img')).forEach((node) => {
const url = node.getAttribute('src');
if (!linksRe.local.test(url))
node.setAttribute('src', proxifyImageUrl(url, true));
......@@ -260,7 +258,7 @@ function linkifyNode(child, state) {
function linkify(content, mutate, hashtags, usertags, images, links) {
// hashtag
content = content.replace(/(^|\s)(#[-a-z\d]+)/gi, tag => {
content = content.replace(/(^|\s)(#[-a-z\d]+)/gi, (tag) => {
if (/#[\d]+$/.test(tag)) return tag; // Don't allow numbers to be tags
const space = /^\s/.test(tag) ? tag[0] : '';
const tag2 = tag.trim().substring(1);
......@@ -290,7 +288,7 @@ function linkify(content, mutate, hashtags, usertags, images, links) {
}
);
content = content.replace(linksAny('gi'), ln => {
content = content.replace(linksAny('gi'), (ln) => {
if (linksRe.image.test(ln)) {
if (images) images.add(ln);
return `<img src="${ipfsPrefix(ln)}" />`;
......@@ -301,9 +299,7 @@ function linkify(content, mutate, hashtags, usertags, images, links) {
// do not linkify phishy links
if (Phishing.looksPhishy(ln))
return `<div title='${getPhishingWarningMessage()}' class='phishy'>${
ln
}</div>`;
return `<div title='${getPhishingWarningMessage()}' class='phishy'>${ln}</div>`;
if (links) links.add(ln);
return `<a href="${ipfsPrefix(ln)}">${ln}</a>`;
......
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const writeStats = require('./utils/write-stats');
const Webpack_isomorphic_tools_plugin = require('webpack-isomorphic-tools/plugin');
......@@ -8,33 +9,46 @@ const webpack_isomorphic_tools_plugin =
new Webpack_isomorphic_tools_plugin(require('./webpack-isotools-config'))
.development();
const css_loaders = [
{
loader: 'style-loader',
const postcss_loader = {
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
'autoprefixer',
],
},
},
};
const css_loaders = [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'autoprefixer-loader'
}
]
postcss_loader,
];
const scss_loaders = [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
url: false,
},
},
{
loader: 'autoprefixer-loader'
},
postcss_loader,
{
loader: 'sass-loader'
}
]
];
module.exports = {
entry: {
app: ['babel-polyfill', './src/app/Main.js'],
app: ['core-js/stable', './src/app/Main.js'],
vendor: [
'react',
'react-dom',
......@@ -56,9 +70,18 @@ module.exports = {
},
module: {
rules: [
{test: /\.(jpe?g|png)/, use: 'url-loader?limit=4096'},
{test: /\.json$/, use: 'json-loader'},
{test: /\.js$|\.jsx$/, exclude: /node_modules/, use: 'babel-loader'},
{
test: /\.(jpe?g|png)/, use: [
{
loader: 'url-loader',
options: {
limit: 4096,
esModule: false,
},
},
],
},
{test: /\.js$|\.jsx$/, exclude: [/node_modules/, /\*\/app\/assets\/static\/\*\.js/], use: 'babel-loader'},
{test: /\.svg$/, use: 'svg-inline-loader'},
{
test: require.resolve("blueimp-file-upload"),
......@@ -70,28 +93,32 @@ module.exports = {
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: scss_loaders
})
use: scss_loaders
},
{
test: /\.md/,
use: 'raw-loader'
use: [
{
loader: 'raw-loader',
options: {
esModule: false,
},
},
],
}
]
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
statsOptions: { source: false }
}),
function () {
this.plugin('done', writeStats);
},
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.CommonsChunkPlugin({
names: 'vendor',
minChunks: Infinity
}),
webpack_isomorphic_tools_plugin,
new ExtractTextPlugin('[name]-[chunkhash].css')
new MiniCssExtractPlugin()
],
resolve: {
alias: {
......
......@@ -12,28 +12,6 @@ module.exports = {
VERSION: JSON.stringify(git.long())
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
sequences: true,
dead_code: true,
drop_debugger: true,
comparisons: true,
conditionals: true,
evaluate: true,
booleans: true,
loops: true,
unused: true,
hoist_funs: true,
if_return: true,
join_vars: true,
cascade: true
},
output: {
comments: false
}
}),
...baseConfig.plugins,
// Fix window.onerror
// See https://github.com/webpack/webpack/issues/5681#issuecomment-345861733
......
......@@ -3,7 +3,7 @@ const fs = require('fs');
const path = require('path');
module.exports = function (stats) {
const publicPath = this.options.output.publicPath;
const publicPath = '/assets/';
const json = stats.toJson();
// get chunks by name and extensions
......
This diff is collapsed.
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