diff --git a/package-lock.json b/package-lock.json index 5ab41011..3e339073 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,9 +11,9 @@ "dev": true }, "@stencil/core": { - "version": "0.0.9-1", - "resolved": "https://registry.npmjs.org/@stencil/core/-/core-0.0.9-1.tgz", - "integrity": "sha512-kCcLfolV2QMVu4iAzIBxiJ9L90jaLRZRvR8ureuDVoAjBQ+VSk7jS3kMGMjnPEHk8ctamj60tGvlkEzYbSmpkg==", + "version": "0.0.9-4", + "resolved": "https://registry.npmjs.org/@stencil/core/-/core-0.0.9-4.tgz", + "integrity": "sha512-P4eUb6UI1hHSsLrRf8rPRwdL/hWXDh/b0Cv6gkPK/iQPD27ARLy/M1mqjptEORpGkVodAE36JogLz+3zN3DG+Q==", "dev": true, "requires": { "chokidar": "1.7.0", @@ -25,6 +25,34 @@ "typescript": "2.6.2", "uglify-es": "3.1.6", "workbox-build": "2.1.1" + }, + "dependencies": { + "node-sass": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.5.3.tgz", + "integrity": "sha1-0JydEXlkEjnRuX/8YjH9zsU+FWg=", + "dev": true, + "requires": { + "async-foreach": "0.1.3", + "chalk": "1.1.3", + "cross-spawn": "3.0.1", + "gaze": "1.1.2", + "get-stdin": "4.0.1", + "glob": "7.1.2", + "in-publish": "2.0.0", + "lodash.assign": "4.2.0", + "lodash.clonedeep": "4.5.0", + "lodash.mergewith": "4.6.0", + "meow": "3.7.0", + "mkdirp": "0.5.1", + "nan": "2.7.0", + "node-gyp": "3.6.2", + "npmlog": "4.1.2", + "request": "2.83.0", + "sass-graph": "2.2.4", + "stdout-stream": "1.4.0" + } + } } }, "@stencil/dev-server": { @@ -2280,6 +2308,21 @@ "globule": "1.2.0" } }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "dev": true + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true, + "requires": { + "is-property": "1.0.2" + } + }, "get-caller-file": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", @@ -2774,6 +2817,18 @@ "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", "dev": true }, + "is-my-json-valid": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz", + "integrity": "sha512-Q2khNw+oBlWuaYvEEHtKSw/pCxD2L5Rc1C+UQme9X6JdRDh7m5D7HkozA0qa3DUkQ6VzCnEm8mVIQPyIRkI5sQ==", + "dev": true, + "requires": { + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "jsonpointer": "4.0.1", + "xtend": "4.0.1" + } + }, "is-npm": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", @@ -2837,6 +2892,12 @@ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "dev": true + }, "is-redirect": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", @@ -3009,6 +3070,12 @@ "graceful-fs": "4.1.11" } }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -3579,9 +3646,9 @@ } }, "node-sass": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.5.3.tgz", - "integrity": "sha1-0JydEXlkEjnRuX/8YjH9zsU+FWg=", + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.7.2.tgz", + "integrity": "sha512-CaV+wLqZ7//Jdom5aUFCpGNoECd7BbNhjuwdsX/LkXBrHl8eb1Wjw4HvWqcFvhr5KuNgAk8i/myf/MQ1YYeroA==", "dev": true, "requires": { "async-foreach": "0.1.3", @@ -3599,9 +3666,149 @@ "nan": "2.7.0", "node-gyp": "3.6.2", "npmlog": "4.1.2", - "request": "2.83.0", + "request": "2.79.0", "sass-graph": "2.2.4", - "stdout-stream": "1.4.0" + "stdout-stream": "1.4.0", + "true-case-path": "1.0.2" + }, + "dependencies": { + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "dev": true + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "dev": true + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "dev": true, + "requires": { + "boom": "2.10.1" + } + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "dev": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "har-validator": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "commander": "2.11.0", + "is-my-json-valid": "2.17.1", + "pinkie-promise": "2.0.1" + } + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "dev": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" + } + }, + "qs": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", + "integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=", + "dev": true + }, + "request": { + "version": "2.79.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", + "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", + "dev": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.11.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "2.0.6", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "qs": "6.3.2", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.4.3", + "uuid": "3.1.0" + } + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "tunnel-agent": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", + "dev": true + } } }, "nopt": { @@ -5025,6 +5232,30 @@ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", "dev": true }, + "true-case-path": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/true-case-path/-/true-case-path-1.0.2.tgz", + "integrity": "sha1-fskRMJJHZsf1c74wIMNPj9/QDWI=", + "dev": true, + "requires": { + "glob": "6.0.4" + }, + "dependencies": { + "glob": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index 319d879d..774ebd3a 100755 --- a/package.json +++ b/package.json @@ -5,15 +5,16 @@ "files": [ "dist/" ], - "browser": "dist/ionicons.js", - "main": "dist/collection/index.js", - "types": "dist/collection/index.d.ts", + "main": "dist/ionicons.js", + "types": "dist/types/index.d.ts", "collection": "dist/collection/collection-manifest.json", "scripts": { - "build": "npm run build.icon && npm run generate && npm run svg-to-js && npm run png && npm run build.docs && npm run build.data", + "build": "npm run build.icon && npm run generate && npm run svg-to-js && npm run png && npm run build.docs && npm run build.data && npm run icon-copy", "build.icon": "stencil build", "build.docs": "stencil build --config src/docs/stencil.config.js", "build.data": "node scripts/data.js", + "build.css": "node scripts/build-css.js", + "icon-copy": "node scripts/copy-svg-to-dist.js", "mode.comparison": "node scripts/mode-comparison.js", "dev": "npm run build.data && sd concurrent \"stencil build --dev --config src/docs/stencil.config.js --watch\" \"stencil-dev-server\" ", "generate": "python scripts/generate.py", @@ -23,10 +24,11 @@ }, "devDependencies": { "@ionic/jpml": "latest", - "@stencil/core": "0.0.9-1", + "@stencil/core": "0.0.9-4", "@stencil/dev-server": "latest", "@stencil/utils": "latest", "fs-extra": "4.0.2", + "node-sass": "4.7.2", "np": "2.17.0", "svg2png": "4.1.1", "svgo": "1.0.3" diff --git a/scripts/build-css.js b/scripts/build-css.js new file mode 100644 index 00000000..12e0f575 --- /dev/null +++ b/scripts/build-css.js @@ -0,0 +1,57 @@ +var sass = require('node-sass'); +var fs = require('fs-extra'); +var path = require('path'); + +var distScssDir = path.join(__dirname, '..', 'dist', 'scss'); +var distCssDir = path.join(__dirname, '..', 'dist', 'css'); + +fs.emptyDirSync(distCssDir); + +generateCss('ionicons'); +generateCss('ionicons-core'); + + +function generateCss(fileName) { + var input = path.join(distScssDir, fileName + '.scss'); + var output = path.join(distCssDir, fileName + '.css'); + + var opts = { + file: input + }; + + sass.render(opts, (err, result) => { + if (err) { + console.log(err); + } else { + fs.writeFile(output, result.css.toString(), { encoding: 'utf-8' }, (err) => { + if (err) { + console.log(err); + } + }) + } + }); +} + + +// def generate_css_from_scss(data): +// try: +// os.makedirs(CSS_FOLDER_PATH) +// except OSError as e: +// if e.errno != errno.EEXIST: +// raise + +// compile_scss_to_css('ionicons', data) +// compile_scss_to_css('ionicons-core', data) + + +// def compile_scss_to_css(filename, data): +// scss_file_path = os.path.join(OUTPUT_SCSS_FOLDER_PATH, '%s.scss' % filename) +// css_file_path = os.path.join(CSS_FOLDER_PATH, '%s.css' % filename) +// css_min_file_path = os.path.join(CSS_FOLDER_PATH, '%s.min.css' % filename) + +// print "Generate CSS From %s" % filename +// cmd = "sass %s %s --style compact" % (scss_file_path, css_file_path) +// call(cmd, shell=True) + +// cmd = "sass %s %s --style compressed" % (scss_file_path, css_min_file_path) +// call(cmd, shell=True) \ No newline at end of file diff --git a/scripts/copy-svg-to-dist.js b/scripts/copy-svg-to-dist.js new file mode 100644 index 00000000..072cfd22 --- /dev/null +++ b/scripts/copy-svg-to-dist.js @@ -0,0 +1,11 @@ +console.log('Copy optimized svg files to dist/ionicons/svg'); + +var fs = require('fs-extra'); +var path = require('path'); + +var optimizedSvgsDir = path.join(__dirname, '..', 'dist', 'collection', 'icon', 'svg'); +var componentSvgDir = path.join(__dirname, '..', 'dist', 'ionicons', 'svg'); + +fs.emptyDirSync(componentSvgDir); + +fs.copy(optimizedSvgsDir, componentSvgDir); diff --git a/scripts/generate.py b/scripts/generate.py index 7ef3e8e7..e2dd3c88 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -200,32 +200,6 @@ def generate_scss(data): f.write( '\n'.join(d) ) f.close() - generate_css_from_scss(data) - - -def generate_css_from_scss(data): - try: - os.makedirs(CSS_FOLDER_PATH) - except OSError as e: - if e.errno != errno.EEXIST: - raise - - compile_scss_to_css('ionicons', data) - compile_scss_to_css('ionicons-core', data) - - -def compile_scss_to_css(filename, data): - scss_file_path = os.path.join(OUTPUT_SCSS_FOLDER_PATH, '%s.scss' % filename) - css_file_path = os.path.join(CSS_FOLDER_PATH, '%s.css' % filename) - css_min_file_path = os.path.join(CSS_FOLDER_PATH, '%s.min.css' % filename) - - print "Generate CSS From %s" % filename - cmd = "sass %s %s --style compact" % (scss_file_path, css_file_path) - call(cmd, shell=True) - - cmd = "sass %s %s --style compressed" % (scss_file_path, css_min_file_path) - call(cmd, shell=True) - def generate_cheatsheet(data): print "Generate Cheatsheet" diff --git a/scripts/readme.md b/scripts/readme.md index 6c8f0cce..600376e2 100644 --- a/scripts/readme.md +++ b/scripts/readme.md @@ -25,14 +25,10 @@ This repo already comes with all the files built and ready to go, but can also b https://github.com/google/woff2 -3) Install [Sass](http://sass-lang.com/) +3) Add or subtract files from the `src/` folder you'd like to be apart of the build. - $ gem install sass +4) Modify any settings in the `scripts/manifest.json` file. You can change the name of the font-family and CSS classname prefix. -4) Add or subtract files from the `src/` folder you'd like to be apart of the build. - -5) Modify any settings in the `scripts/manifest.json` file. You can change the name of the font-family and CSS classname prefix. - -6) Run the build command: +5) Run the build command: npm run build diff --git a/scripts/svg-to-js.js b/scripts/svg-to-js.js index 7729b683..f370c100 100644 --- a/scripts/svg-to-js.js +++ b/scripts/svg-to-js.js @@ -5,7 +5,6 @@ var fs = require('fs-extra'); var path = require('path'); const OUT_DIR = [ - path.join(__dirname, '..', 'dist', 'ionicons', 'svg'), path.join(__dirname, '..', 'dist', 'collection', 'icon', 'svg') ]; diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx index 50537024..f343b47e 100755 --- a/src/components/icon/icon.tsx +++ b/src/components/icon/icon.tsx @@ -33,6 +33,8 @@ export class Icon { */ @Prop() name = ''; + @Prop({ context: 'publicPath'}) private publicPath: string; + @Prop({ context: 'isServer'}) private isServer: boolean; @State() private svgContent: string = null; @@ -124,7 +126,7 @@ export class Icon { // haven't loaded this svg yet // start the request - loadSvgContent(iconName, loadedSvgContent => { + loadSvgContent(iconName, this.publicPath, loadedSvgContent => { // we're finished loading the svg content! // set to this.svgContent so we do another render this.svgContent = loadedSvgContent; @@ -137,7 +139,7 @@ export class Icon { } -function loadSvgContent(iconName: string, callback: {(loadedSvgContent: string): void}) { +function loadSvgContent(iconName: string, publicPath: string, callback: {(loadedSvgContent: string): void}) { // static since all IonIcons use this same function and pointing at global/shared data // passed in callback will have instance info diff --git a/src/components/index.d.ts b/src/components/index.d.ts new file mode 100644 index 00000000..ae5e19d1 --- /dev/null +++ b/src/components/index.d.ts @@ -0,0 +1,2 @@ + +export * from './components'; diff --git a/src/docs/stencil.config.js b/src/docs/stencil.config.js index e2743172..6da3a0cf 100644 --- a/src/docs/stencil.config.js +++ b/src/docs/stencil.config.js @@ -2,9 +2,5 @@ exports.config = { namespace: 'DocsSite', srcDir: 'site/', wwwDir: '../../docs/', - copy: [ - { src: '../../../dist/css', dest: 'css' }, - { src: '../../../dist/fonts', dest: 'fonts' } - ], serviceWorker: false }; diff --git a/stencil.config.js b/stencil.config.js index 2fa285a6..b13d5bdb 100755 --- a/stencil.config.js +++ b/stencil.config.js @@ -3,8 +3,7 @@ exports.config = { generateDistribution: true, generateWWW: false, distDir: 'dist/', - srcDir: 'src/components/', - emptyDist: false + srcDir: 'src/components/' }; exports.devServer = {