const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MinifyPlugin = require("babel-minify-webpack-plugin");
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
devServer: {
overlay: true
},
optimization: {
minimizer: [new OptimizeCSSAssetsPlugin({})],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: '/node_modules/'
},
{
test: /\.sass$/,
use: [
{ loader: MiniCssExtractPlugin.loader},
{ loader: 'css-loader?url=false' },
{
loader: "postcss-loader",
options: {
ident: 'postcss',
plugins: [
require('autoprefixer')
]
}
},
'sass-loader'
]
},
{
test: /\.(png|jpe?g|gif)$/,
use: [
{
loader: 'file-loader',
options: {},
},
],
}
]
},
plugins: [
new MiniCssExtractPlugin({ filename: '[name].css'}),
new MinifyPlugin(),
new HtmlWebpackPlugin({
template : './src/index.html'
}),
new CopyPlugin([
{
from: path.join(__dirname, '/src/img'),
to: 'img'
},
])
],
devtool: 'cheap-eval-source-map'
};
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.6",
"babel-minify-webpack-plugin": "^0.3.1",
"copy-webpack-plugin": "^5.0.3",
"css-loader": "^3.0.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.7.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"path": "^0.12.7",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.6.0",
"sass-loader": "^7.1.0",
"webpack": "^4.35.0",
"webpack-cli": "^3.3.4",
"webpack-dev-server": "^3.7.1"
},
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
let xhr = new XMLHttpRequest;
xhr.open('GET', link, true);
xhr.send();
xhr.onload = () => {
let response = JSON.parse(xhr.responseText);
response['data'].forEach( elem => {
let img = document.createElement('img');
img.src = elem['images']['480w_still']['url'];
img.style.width = '100%';
img.onload = () => addGifs(img);
})
}
function addGifs(img) {
let minIndex = 0;
let columnsHeight = options.columns.map( column => {
return column.offsetHeight;
});
console.log(columnsHeight, minIndex);
for (let i = 0; i < columnsHeight.length; i++) {
if (columnsHeight[minIndex] > columnsHeight[i]) {
minIndex = i;
}
}
options.columns[minIndex].append(img);
}
react-domproduction-min.js = 400+kb