Skip to content

Commit

Permalink
fix: remove IE support #181
Browse files Browse the repository at this point in the history
Change to be Committed:

modified: template/package.json
modified: template/scripts/postCss.js
deleted: template/babel.config.js
deleted: template/index.html
deleted: template/rollup.config.js
deleted: template/scripts/removeNonRemPlugin.js
deleted: template/src/es5.js
deleted: template/src/style-fixed.scss
newfile: template/rollup.config.mjs
  • Loading branch information
irma-kurnia-phtn committed Apr 25, 2023
1 parent d09e979 commit 0106481
Showing 9 changed files with 28 additions and 273 deletions.
53 changes: 0 additions & 53 deletions template/babel.config.js

This file was deleted.

15 changes: 0 additions & 15 deletions template/index.html

This file was deleted.

20 changes: 2 additions & 18 deletions template/package.json
Original file line number Diff line number Diff line change
@@ -25,33 +25,23 @@
},
"peerDependencies": {
"@alaskaairux/design-tokens": "",
"@alaskaairux/webcorestylesheets": "",
"@webcomponents/webcomponentsjs": ""
"@alaskaairux/webcorestylesheets": ""
},
"devDependencies": {
"@alaskaairux/design-tokens": "",
"@alaskaairux/webcorestylesheets": "",
"@aurodesignsystem/eslint-config": "",
"@babel/core": "",
"@babel/plugin-syntax-dynamic-import": "",
"@babel/plugin-transform-runtime": "",
"@babel/preset-env": "",
"@babel/runtime": "",
"@commitlint/cli": "",
"@commitlint/config-conventional": "",
"@open-wc/testing": "",
"@rollup/plugin-alias": "",
"@rollup/plugin-babel": "",
"@rollup/plugin-commonjs": "",
"@open-wc/testing-karma": "",
"@rollup/plugin-node-resolve": "",
"@semantic-release/changelog": "",
"@semantic-release/git": "",
"@semantic-release/npm": "",
"@web/dev-server": "",
"@web/test-runner": "",
"@webcomponents/webcomponentsjs": "",
"autoprefixer": "",
"babel-loader": "",
"compression": "",
"concat": "",
"concurrently": "",
@@ -66,16 +56,11 @@
"nodemon": "",
"npm-run-all": "",
"postcss": "",
"postcss-custom-properties": "",
"postcss-discard-comments": "",
"postcss-rem-to-pixel": "",
"postcss-remove-rules": "",
"postcss-selector-replace": "",
"prismjs": "",
"rollup": "",
"rollup-plugin-minify-html-literals": "",
"rollup-plugin-serve": "",
"rollup-plugin-terser": "",
"semantic-release": "",
"sass": "",
"stylelint": "",
@@ -93,7 +78,6 @@
"browserslist": [
"last 2 Chrome versions",
"last 2 iOS major versions",
"ie 11",
"last 2 Firefox versions",
"last 2 Edge versions",
"last 2 Safari major versions"
65 changes: 0 additions & 65 deletions template/rollup.config.js

This file was deleted.

24 changes: 24 additions & 0 deletions template/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import serve from 'rollup-plugin-serve';

const production = !process.env.ROLLUP_WATCH,

modernConfig = {
input: {
['[namespace]-[name]__bundled']: './index.js',
},
output: {
format: 'esm',
dir: 'dist/'
},
plugins: [
nodeResolve(),
!production &&
serve({
open: true,
openPage: '/docs/'
})
]
};

export default [modernConfig];
84 changes: 2 additions & 82 deletions template/scripts/postCss.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
const autoprefixer = require('autoprefixer');
const chalk = require('chalk');
const postcss = require('postcss');
const remToPx = require('postcss-rem-to-pixel');
const removeNonRem = require('./removeNonRemPlugin.js');
const postcssCustomProperties = require('postcss-custom-properties');
const removeRules = require('postcss-remove-rules');
const comments = require('postcss-discard-comments');
const path = require('path');
const fs = require('fs');
const directoryPath = path.join(__dirname, '../src');
let cssFiles = [];
let fixedCssFiles = [];

/**
* Default postCSS run
@@ -29,95 +24,20 @@ fs.readdir(directoryPath, function (err, files) {
});
});

/**
* Addresses postCSS run of style-fixed files.
*/
fs.readdir(directoryPath, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
//listing all files using forEach
files.forEach(function (file) {
if (file.includes("-fixed.css")) {
fixedCssFiles.push(file.replace(".css", "").replace("-fixed", ""));
fixedProcessor(file);
}
});
});

/**
* The standardProcessor function applies tokens for fallback selectors
* and completes a post cleanup.
* @param {string} file
*/
function standardProcessor(file) {
fs.readFile(`src/${file}`, (err, css) => {
postcss([autoprefixer, postcssCustomProperties, comments])
.use(comments({
remove: function(comment) { return comment[0] == "@"; }
}))
.use(removeRules({
rulesToRemove: {
':root': '*'
}
}))
.process(css, { from: `src/${file}`, to: `src/${file}` })
.then(result => {
fs.writeFile(`src/${file}`, result.css, () => true)
})
});
}

/**
* Output a "fixed" stylesheet that only contains
* declarations with rem units converted to their px equivalent.
* @param {string} file
*/
function fixedProcessor(file) {
fs.readFile(`src/${file}`, (err, css) => {
postcss([
autoprefixer,
postcssCustomProperties({preserve: false}),
comments,
removeNonRem,
remToPx({replace: true, propList: ['*']})
])
postcss([autoprefixer, comments])
.use(comments({
remove: function(comment) { return comment[0] == "@"; }
}))
.process(css, { from: `src/${file}`, to: `src/${file}` })
.then(result => {
.then((result) => {
fs.writeFile(`src/${file}`, result.css, () => true)
})
});
}

/**
* Function to compare generated arrays based on CSS files in ./src dir.
* Purpose to print warning to user if necessary files are not created.
* @param {array} a
* @param {array} b
*/
function compareLists(a, b) {
const result = a.every((val, index) => val === b[index])

if (!result) {
console.log(chalk.hex('#f26135')(`
╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮
WARNING!! It's been detected that your list of CSS
files is not equal to the required '-fixed' versions.
╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
`));
}
}

/**
* Timeout function to allow for generation of arrays
* to be compared in compareLists() function.
*/
setTimeout(function() {
compareLists(cssFiles, fixedCssFiles);
}, 500);
27 changes: 0 additions & 27 deletions template/scripts/removeNonRemPlugin.js

This file was deleted.

8 changes: 0 additions & 8 deletions template/src/es5.js

This file was deleted.

5 changes: 0 additions & 5 deletions template/src/style-fixed.scss

This file was deleted.

0 comments on commit 0106481

Please sign in to comment.