Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postinstall step to build lib and dist if they don't already exist. #222

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
"react-ace": "5.5.0",
"serve": "6.3.1",
"tabbable": "1.1.0",
"uuid": "3.1.0"
},
"devDependencies": {
"uuid": "3.1.0",
"@elastic/eslint-config-kibana": "0.13.0",
"autoprefixer": "7.1.5",
"babel-cli": "6.26.0",
Expand Down
12 changes: 11 additions & 1 deletion scripts/compile-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@

set -e

rm -rf dist lib
eui="$(pwd)"

while getopts 'e:' arg
do
case ${arg} in
e) eui=${OPTARG};;
*) return 1 # illegal option
esac
done

rm -rf "${eui}/dist" "${eui}/lib"
28 changes: 19 additions & 9 deletions scripts/compile-eui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

set -e

eui="$(pwd)"

while getopts 'e:' arg
do
case ${arg} in
e) eui=${OPTARG};;
*) return 1 # illegal option
esac
done

compile_lib() {
local color_green="\033[0;32m"
local color_reset="\033[0m"

mkdir -p lib/components lib/services lib/test
mkdir -p "${eui}/lib/components" "${eui}/lib/services" "${eui}/lib/test"

# We use tput below to save the cursor position, then restore it later in
# order to overwrite "processing" messages.
Expand All @@ -15,30 +25,30 @@ compile_lib() {
echo -n " Compiling src/ to lib/ " >&2
babel \
--quiet \
--out-dir=lib \
--out-dir="${eui}/lib" \
--ignore "**/webpack.config.js,**/*.test.js" \
src
"${eui}/src"
tput rc
echo -e "${color_green}✔ Finished compiling src/ to lib/${color_reset}" >&2

# Also copy over SVGs. Babel has a --copy-files option but that brings over
# all kinds of things we don't want into the lib folder.
mkdir -p lib/components/icon/assets
for SVG in $(cd src && find components -name \*.svg); do
cp "src/$SVG" "lib/$SVG"
mkdir -p "${eui}/lib/components/icon/assets"
for SVG in $(cd "${eui}/src" && find components -name \*.svg); do
cp "${eui}/src/$SVG" "${eui}/lib/$SVG"
done

echo -e "${color_green}✔ Finished copying SVGs${color_reset}" >&2
}

compile_bundle() {
mkdir -p dist
mkdir -p "${eui}/dist"

echo -e "\nBuilding bundle...\n" >&2
webpack --config=src/webpack.config.js
webpack --config="${eui}/src/webpack.config.js"

echo -e "\nBuilding minified bundle...\n" >&2
NODE_ENV=production webpack --config=src/webpack.config.js
NODE_ENV=production webpack --config="${eui}/src/webpack.config.js"
}

compile_lib
Expand Down
21 changes: 17 additions & 4 deletions scripts/compile-scss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

set -e

mkdir -p dist
eui="$(pwd)"

for THEME in src/theme_*.scss; do
node-sass "$THEME" > "dist/eui_$(basename "$THEME" .scss).css"
postcss --replace --config src-docs/postcss.config.js "dist/eui_$(basename "$THEME" .scss).css"
while getopts 'e:' arg
do
case ${arg} in
e) eui=${OPTARG};;
*) return 1 # illegal option
esac
done

mkdir -p "${eui}/dist"

src="${eui}/src/theme_*.scss"

for THEME in $src; do
dest="${eui}/dist/eui_$(basename "$THEME" .scss).css"
node-sass "$THEME" > "$dest"
postcss --replace --config "${eui}/src-docs/postcss.config.js" "$dest"
done
16 changes: 13 additions & 3 deletions scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -e

./scripts/compile-clean.sh
./scripts/compile-scss.sh
./scripts/compile-eui.sh
eui="$(pwd)"

while getopts 'e:' arg
do
case ${arg} in
e) eui=${OPTARG};;
*) return 1 # illegal option
esac
done

"${eui}/scripts/compile-clean.sh"
"${eui}/scripts/compile-scss.sh"
"${eui}/scripts/compile-eui.sh"
4 changes: 2 additions & 2 deletions src/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ module.exports = {
loaders: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
include: path.resolve(__dirname, '../src'),
}, {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
exclude: /node_modules/
include: path.resolve(__dirname, '../src'),
}, {
test: /\.(woff|woff2|ttf|eot|ico|png|gif|jpg|jpeg)(\?|$)/,
loader: 'file-loader',
Expand Down