Skip to content

Commit

Permalink
performance updates
Browse files Browse the repository at this point in the history
  • Loading branch information
igdev0 committed Oct 23, 2019
1 parent 0683584 commit 0fcc342
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 121 deletions.
1 change: 0 additions & 1 deletion dev/icons/arrow-left.svg

This file was deleted.

1 change: 0 additions & 1 deletion dev/icons/arrow-right.svg

This file was deleted.

2 changes: 0 additions & 2 deletions dev/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import polyfills from './scripts/polyfills';
import Controllers from './scripts/controllers';
import './scss/styles.scss';

polyfills();
// Options provided:
// - slider_container: # It should be a element wich contains slides. Otherwise it will look for an element with the attribute named data-carousel="name"
Expand Down
116 changes: 116 additions & 0 deletions dist/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
html,
body {
margin: 0;
padding: 0; }

.current-slide {
z-index: 1; }

.page-active {
background: #fff; }

/*The height is required in order to see the image*/
.tidy__carousel-wrapper {
position: relative;
width: 100%;
height: 100%; }

.tidy__carousel {
position: relative;
height: 30vmin;
width: 100%;
margin: 0;
padding: 0;
z-index: 1;
display: block;
overflow: hidden; }

.tidy__carousel .tidy__carousel-slide {
position: absolute;
width: inherit;
height: inherit;
display: inline-block; }

.tidy__carousel .tidy__carousel-slide > * {
width: inherit;
height: inherit;
display: block;
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none; }

button.tidy__carousel-controller[data-carousel-controller] {
position: absolute;
transform: translateY(-50%);
z-index: 1000;
top: 50%;
width: 44px;
height: 44px;
border-radius: 50%;
background: #fff;
border: none;
z-index: 10;
display: block;
background: #fff;
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none;
outline: none;
cursor: pointer; }
button.tidy__carousel-controller[data-carousel-controller] svg {
position: absolute;
left: 20%;
top: 20%;
width: 60%;
height: 60%;
cursor: pointer;
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none; }

button.tidy__carousel-controller[data-carousel-controller~="left"] {
left: 10px; }

button.tidy__carousel-controller[data-carousel-controller~="right"] {
right: 10px; }

.tidy__carousel-pager[data-carousel-pager] {
position: relative;
margin: 0;
padding: 0;
z-index: 100;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
transform: translateY(-25px);
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none; }
.tidy__carousel-pager[data-carousel-pager] .tidy__carousel-pager--page {
margin: 0 5px;
width: 10px;
height: 10px;
border-radius: 100%;
border: 1px solid #f1f1f1;
cursor: pointer;
list-style-type: none;
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none; }

2 changes: 2 additions & 0 deletions dist/styles.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 22 additions & 57 deletions dist/tidy-carousel.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tidy-carousel.min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@
],
"scripts": {
"start": "webpack-dev-server",
"prod": "webpack --mode production",
"dev": "webpack --mode development",
"build": "webpack --mode production && webpack --mode development",
"test" : "echo \"Error: no test specified\" && exit 0"
"prod": "webpack --env production webpack.config.js",
"dev": "webpack webpack.config.js",
"build": "webpack --env production && webpack --mode development",
"test": "echo \"Error: no test specified\" && exit 0"
},
"author": "Dorultan Ianos",
"license": "MIT",
"devDependencies": {
"babel-loader": "^8.0.6",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-loader": "^8.0.6",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"css-loader": "^3.0.0",
"enzyme": "^3.10.0",
"express": "^4.17.1",
"jquery": "^3.4.1",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^2.2.1",
"url-loader": "^2.0.0",
"webpack": "^4.34.0",
"webpack-cli": "^3.3.4",
Expand Down
119 changes: 65 additions & 54 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,71 @@
const path = require('path');
const webpack = require('webpack');
const argv = process.argv;
const idx_of_mode = argv.indexOf('--mode');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');

const config = {
name: 'client',
mode: process.env.NODE_ENV || 'development',
entry: ['./dev/index'],
output: {
publicPath: './dist',
path: path.resolve(__dirname, 'dist'),
filename: `tidy-carousel${argv[idx_of_mode ? idx_of_mode + 1 : 0] === 'production' ? '.min.js' : '.js'}`,
library: 'TidyCarousel',
libraryTarget: 'umd',
libraryExport: 'default',
globalObject: "typeof self !== 'undefined' ? self : this"
},
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
plugins: [
new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production") }),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.NoEmitOnErrorsPlugin()
],
module: {
rules: [
{
test: /\.scss/,
use: [
{loader: "style-loader"},
{loader: "css-loader"},
{loader: "sass-loader", options: {includePaths: ["./dev/scss", './dev/sass']}}
]
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
fallback: 'responsive-loader',
},
},
],
}
]
},
module.exports = (env, argv) => {

devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
writeToDisk: true,
port: 8080
}
}
return {
name: 'client',
mode: env === 'production' ? 'production' : 'development',
entry: ['./dev/index'],
output: {
publicPath: '/dist',
path: path.resolve(__dirname, 'dist'),
pathinfo: false,
filename: `tidy-carousel${env === 'production' ? '.min.js' : '.js'}`,
library: 'TidyCarousel',
libraryTarget: 'umd',
libraryExport: 'default',
globalObject: "typeof self !== 'undefined' ? self : this"
},
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'dev'),
loader: 'babel-loader',
},
{
test: /\.scss$/,
use: [
{loader: MiniCssExtractPlugin.loader},
{loader: "css-loader"},
{loader: "sass-loader", options: {includePaths: ["./dev/scss", './dev/sass']}},
]
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
fallback: 'responsive-loader',
},
},
],
}
]
},

module.exports = config;
plugins: [
// new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production") }),
new MiniCssExtractPlugin({
filename: env === 'production' ? 'styles.min.css' : 'styles.css'
})
],

devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
writeToDisk: true,
port: 8080
}
};
};

0 comments on commit 0fcc342

Please sign in to comment.