Skip to content

Commit

Permalink
fix: styling
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Feb 26, 2021
1 parent 299b88a commit 7f3b8a4
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 80 deletions.
10 changes: 5 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module.exports = {
preset: 'ts-jest',
testRegex: '((\\.|/)(test|spec))\\.[jt]sx?$',
testRegex: 'tests/.*\\.spec\\.(ts|tsx|js)$',
globals: {
'ts-jest': {
tsConfig: 'tsconfig.test.json',
diagnostics: true,
babelConfig: false
}
}
// diagnostics: true,
// babelConfig: false,
},
},
};
4 changes: 2 additions & 2 deletions tests/abortAble.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import abortAble, { ABORTED, isAbortAble } from '../src/abortAble';

function resolveIn<T>(this: any, ms: number, result?: T) {
return new Promise<T>((resolve) => {
self.setTimeout(resolve.bind(this, result), ms);
setTimeout(resolve.bind(this, result), ms);
});
}

Expand Down Expand Up @@ -62,7 +62,7 @@ describe('utils', () => {
expect(typeof isAbortAble).toBe('function');
expect(isAbortAble(null)).toBe(false);
expect(isAbortAble(undefined)).toBe(false);
expect(isAbortAble(<any>Promise.resolve(false))).toBe(false);
expect(isAbortAble(Promise.resolve(false))).toBe(false);
expect(isAbortAble(abortAble(Promise.resolve(false)).then(() => true))).toBe(true);
});
});
2 changes: 1 addition & 1 deletion tests/logic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('logic', () => {
acc[acc.length - 1].height = indexOrHeight;
}
return acc;
}, <{ index: number; height: number }[]>[]);
}, [] as { index: number; height: number }[]);

expect(ex.size).toBe(checks.length);

Expand Down
148 changes: 76 additions & 72 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-env node */

const resolve = require('path').resolve;
Expand All @@ -7,11 +8,14 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const now = new Date();
const prefix = (n) => n < 10 ? ('0' + n) : n.toString();
const buildId = `${now.getUTCFullYear()}${prefix(now.getUTCMonth() + 1)}${prefix(now.getUTCDate())}-${prefix(now.getUTCHours())}${prefix(now.getUTCMinutes())}${prefix(now.getUTCSeconds())}`;
const prefix = (n) => (n < 10 ? '0' + n : n.toString());
const buildId = `${now.getUTCFullYear()}${prefix(now.getUTCMonth() + 1)}${prefix(now.getUTCDate())}-${prefix(
now.getUTCHours()
)}${prefix(now.getUTCMinutes())}${prefix(now.getUTCSeconds())}`;

const year = (new Date()).getFullYear();
const banner = `/*! ${pkg.title || pkg.name} - v${pkg.version} - ${year}\n` +
const year = new Date().getFullYear();
const banner =
`/*! ${pkg.title || pkg.name} - v${pkg.version} - ${year}\n` +
(pkg.homepage ? `* ${pkg.homepage}\n` : '') +
`* Copyright (c) ${year} ${pkg.author.name}; Licensed ${pkg.license} */\n`;

Expand All @@ -22,37 +26,39 @@ module.exports = (_env, options) => {
const dev = options.mode.startsWith('d');
return {
node: false, // no polyfills
entry: !dev ? {
lineupengine: './src/bundle.ts',
} : {
lineupengine: './src/index.ts',
demo: './demo/index.ts',
table: './demo/table.ts',
cell: './demo/cell.ts'
},
entry: !dev
? {
lineupengine: './src/bundle.ts',
}
: {
lineupengine: './src/index.ts',
demo: './demo/index.ts',
table: './demo/table.ts',
cell: './demo/cell.ts',
},
output: {
path: resolve(__dirname, 'build'),
filename: `[name].js`,
chunkFilename: '[chunkhash].js',
publicPath: '', //no public path = relative
library: pkg.global,
libraryTarget: 'umd',
umdNamedDefine: false //anonymous require module
umdNamedDefine: false, //anonymous require module
},
resolve: {
extensions: ['.ts', '.tsx', '.mjs', '.js'],
symlinks: false
symlinks: false,
},
plugins: [
new webpack.BannerPlugin({
banner: banner,
raw: true
raw: true,
}),
//define magic constants that are replaced
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__LICENSE__: JSON.stringify(pkg.license),
__BUILD_ID__: JSON.stringify(buildId)
__BUILD_ID__: JSON.stringify(buildId),
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
Expand All @@ -61,75 +67,73 @@ module.exports = (_env, options) => {
chunkFilename: '[id].css',
}),
new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: true
})
checkSyntacticErrors: true,
}),
],
externals: {},
module: {
rules: [{
test: /\.s?css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [{
loader: 'cache-loader'
rules: [
{
test: /\.s?css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
loader: 'thread-loader',
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'cache-loader',
},
{
loader: 'thread-loader',
options: {
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
workers: require('os').cpus().length - 1,
},
},
{
loader: 'ts-loader',
options: {
configFile: dev ? 'tsconfig.dev.json' : 'tsconfig.json',
happyPackMode: true, // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
},
},
].slice(process.env.CI || !dev ? 2 : 0), // no optimizations for CIs and in production mode
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader',
options: {
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
workers: require('os').cpus().length - 1,
limit: 20000, //inline <= 10kb
},
},
{
loader: 'ts-loader',
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
configFile: dev ? 'tsconfig.dev.json' : 'tsconfig.json',
happyPackMode: true // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
}
}
].slice(process.env.CI || !dev ? 2 : 0) // no optimizations for CIs and in production mode
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader',
options: {
limit: 20000 //inline <= 10kb
}
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
limit: 20000, //inline <= 20kb
mimetype: 'application/font-woff'
}
},
{
test: /\.svg(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
limit: 10000, //inline <= 10kb
mimetype: 'image/svg+xml'
}
},
{
test: /\.(ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}
]
limit: 20000, //inline <= 20kb
mimetype: 'application/font-woff',
},
},
{
test: /\.svg(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
limit: 10000, //inline <= 10kb
mimetype: 'image/svg+xml',
},
},
{
test: /\.(ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
},
],
},
watchOptions: {
ignored: /node_modules/
ignored: /node_modules/,
},
devServer: {
contentBase: 'demo'
}
contentBase: 'demo',
},
};
};

0 comments on commit 7f3b8a4

Please sign in to comment.