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

fix: Missing super-tabs.scss file #248

Closed
wants to merge 2 commits into from
Closed

Conversation

gvhuyssteen
Copy link

Copy super-tabs.scss to dist/components directory so that it ends up with the published package.

Inspired by @allanpoppe

allanpoppe@b33ffdd#diff-b9cfc7f2cdf78a7f4b91a753d10865a2

Gerrit van Huyssteen added 2 commits January 11, 2018 08:42
Copy super-tabs.scss to dist/components directory so that it ends up with the published package
Forgot to add `npm` in front of `run postbuild`
@gvhuyssteen
Copy link
Author

gvhuyssteen commented Jan 16, 2018

A temporary solution for now is to create a hook.

Step 1
In the root of the project, create a folder called scripts and a child folder called ionic2-super-tabs-fix. (The traditional way of creating a hooks folder does not work)

scripts/ionic2-super-tabs-fix/

Step 2
Inside of the child directory, create a javascript file and call it setStyleSheet.js

scripts/ionic2-super-tabs-fix/set-style-sheet.js

Step 3
Copy https://raw.githubusercontent.com/zyra/ionic2-super-tabs/master/src/components/super-tabs.scss into the child directory.

scripts/ionic2-super-tabs-fix/super-tabs.scss

Step 4
Open scripts/ionic2-super-tabs-fix/set-style-sheet.js and paste the following script:

#!/usr/bin/env node

var fs = require('fs');
module.exports = function(context) {
  // Include ionic2-super-tabs into node package
  fs.createReadStream('./scripts/ionic2-super-tabs-fix/super-tabs.scss').pipe(fs.createWriteStream('./node_modules/ionic2-super-tabs/dist/components/super-tabs.scss'));
};

Step 5
Edit the config.xml file and register the hook inside of the android platform tag.
<hook src="scripts/ionic2-super-tabs-fix/set-style-sheet.js" type="before_prepare" />

This hook will run every time cordova build is called.
Ref: https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/

This is an excerpt of the config.xml file just to show the location of where to register the hook

<?xml version='1.0' encoding='utf-8'?>
<widget ...>
    ...
    <platform name="android">
        <hook src="scripts/ionic2-super-tabs-fix/set-style-sheet.js" type="before_prepare" />
        ....
    </platform>
    ....
</widget>

Step 6
From your terminal, run ionic cordova build.
This will trigger the hook and copy the sass file into the node_modules directory where it belongs.
(You might have to run it twice as before_prepare is called slightly after Cordova packages the node_modules and will not be included in the first run)

@ihadeed
Copy link
Member

ihadeed commented Jan 25, 2018

postbuild runs after build though.

Is this a new issue introduced by a specific NPM version?

@ihadeed ihadeed closed this Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants