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

Pull Bulma, FA, OpenSans from NPM repository instead of including from CDN #286

Merged
merged 5 commits into from
Jul 5, 2019

Conversation

rabejens
Copy link

@rabejens rabejens commented Jun 30, 2019

This PR causes Bulma, FontAwesome Free and OpenSans to be pulled from NPM repository instead of CDN. This makes it possible to use SAFE applications on machines without any connection to the Internet.

Related discussion: #281

@rabejens rabejens changed the title Local webdeps Pull Bulma, FA, OpenSans from NPM repository instead of including from CDN Jun 30, 2019
@rabejens
Copy link
Author

For some reason, this builds perfectly on Windows. I am currently setting up an environment in WSL Ubuntu and trying to reproduce the error.

@rabejens
Copy link
Author

When running the tests in WSL Ubuntu, I get this:

Parsing ./src/Client/Client.fsproj...
fable: Compiled src/Client/Client.fsproj
fable: Compiled src/Client/Client.fs
fable: Compiled src/Client/Version.fs
fable: Compiled src/Shared/Shared.fs
fable: Compiled .fable/Fulma.2.1.0/Layouts/Container.fs
fable: Compiled .fable/Fulma.2.1.0/Layouts/Hero.fs
fable: Compiled .fable/Fulma.2.1.0/Layouts/Tile.fs
fable: Compiled .fable/Fulma.2.1.0/Components/Menu.fs
fable: Compiled .fable/Fulma.2.1.0/Components/Breadcrumb.fs
fable: Compiled .fable/Fulma.2.1.0/Components/Navbar.fs
fable: Compiled .fable/Fulma.2.1.0/Layouts/Column.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Box.fs
fable: Compiled .fable/Fulma.2.1.0/Components/Card.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Table.fs
fable: Compiled .fable/Fulma.2.1.0/Layouts/Columns.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Icon.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Form/Control.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Heading.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Content.fs
fable: Compiled .fable/Fable.Elmish.3.0.0/cmd.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Form/Field.fs
fable: Compiled .fable/Fulma.2.1.0/Common.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Form/Input.fs
fable: Compiled .fable/Fable.FontAwesome.2.0.0/FontAwesome.fs
fable: Compiled .fable/Fulma.2.1.0/Elements/Button.fs
fable: Compiled .fable/Fable.Elmish.React.3.0.1/react.fs
fable: Compiled .fable/Fable.Elmish.3.0.0/program.fs
fable: Compiled .fable/Fable.Remoting.Client.5.3.0/Remoting.fs
fable: Compiled .fable/Fable.Elmish.3.0.0/prelude.fs
fable: Compiled .fable/Fable.Remoting.Client.5.3.0/Types.fs
fable: Compiled .fable/Fable.React.5.2.3/Fable.React.Props.fs
fable: Compiled .fable/Fable.Elmish.React.3.0.1/common.fs
fable: Compiled .fable/Fable.Elmish.3.0.0/ring.fs
fable: Compiled .fable/Fable.Remoting.Client.5.3.0/Proxy.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/TypeInfo.Converter.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/TypeInfo.fs
fable: Compiled .fable/Fable.Remoting.Client.5.3.0/Http.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/SimpleJson.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/Json.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/TypeCheck.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/Json.Converter.fs
fable: Compiled .fable/Fable.SimpleJson.3.0.0/Parser.fs
fable: Compiled .fable/Fable.Parsimmon.4.0.0/Parsimmon.fs
Unhandled rejection Error: original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.
    at SourceMapGenerator_validateMapping [as _validateMapping] (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/source-map/lib/source-map-generator.js:276:15)
    at SourceMapGenerator_addMapping [as addMapping] (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/source-map/lib/source-map-generator.js:110:12)
    at /tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/source-map/lib/source-map-generator.js:72:17
    at Array.forEach (<anonymous>)
    at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/source-map/lib/source-map-consumer.js:157:14)
    at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/source-map/lib/source-map-generator.js:48:24)
    at SourceMapSource.node (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/webpack-sources/lib/SourceMapSource.js:32:35)
    at SourceMapSource.proto.sourceAndMap (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/webpack-sources/lib/SourceAndMapMixin.js:30:18)
    at getTaskForFile (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/webpack/lib/SourceMapDevToolPlugin.js:37:30)
    at files.forEach (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/webpack/lib/SourceMapDevToolPlugin.js:136:20)
    at Array.forEach (<anonymous>)
    at compilation.hooks.afterOptimizeChunkAssets.tap (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/webpack/lib/SourceMapDevToolPlugin.js:130:12)
    at SyncHook.eval [as call] (eval at create (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/tapable/lib/Hook.js:154:20)
    at hooks.optimizeChunkAssets.callAsync.err (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/webpack/lib/Compilation.js:1315:42)
    at _err0 (eval at create (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
    at taskRunner.run (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/terser-webpack-plugin/dist/index.js:319:9)
    at step (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/terser-webpack-plugin/dist/TaskRunner.js:87:9)
    at done (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/terser-webpack-plugin/dist/TaskRunner.js:98:30)
    at tryCatcher (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/tmp/3812baf7cd274a1c8683b9b349c13169/node_modules/bluebird/js/release/promise.js:699:18)

I don't know what to do against it. @theimowski can you have a look at it?


//#if (layout != "none")
// FontAwesome
$fa_font_path: "~@fortawesome/fontawesome-free/webfonts";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it normal to load both FontAwesome and OpenSans icons at the same time?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSans is not for icons, it is for the overall fonts, at least that's what I understood.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I added open sans there as some of the fulma templates used it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we could remove it as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I meant we still use it when you specify --layout fulma-hero for example. So don't remove it for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here you include it for all the layouts because it's (layout != "none") no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is not perfectly valid here, currently layout can be one of:

  • none
  • fulma-basic
  • fulma-hero
  • ... (other fulma templates)

Not sure here but probably fulma-basic doesn't need the font, so it would be better to have layout != "none" && layout != "fulma-basic" but I was too lazy for that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End game is we want to eventually leave just none and fulma-basic so we could remove the font then

@theimowski
Copy link
Member

When testing the PR locally I get following error:

Template "SAFE-Stack Web App v1.10.0" could not be created.
Error while processing file /Content/src/Client/style.scss
Non-negative number required.
Parameter name: srcOffset

never seen that before

@theimowski
Copy link
Member

Interestingly, removing final newline from *.scss fixed the issue for me
BTW the azure pipelines build doesn't yet work currently, so please just look at the Travis one - @isaacabraham can you disable the Azure Pipelines build until it's ready?

@@ -24,5 +30,13 @@
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14",
"whatwg-fetch": "^3.0.0"
//#if (layout != "none")
},
"dependencies": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these need to be in dependencies, or can we move them to devDependencies?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, I'm sorry, but I can try if it works with devDependencies when I return home from work.

@@ -8,16 +8,16 @@
"@babel/runtime": "^7.4.4",
//#if (layout != "none")
"@fortawesome/fontawesome-free": "^5.9.0",
"file-loader": "^4.0.0",
"bulma": "^0.7.1",
"open-sans-fonts": "^1.5.1",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making all dependencies devDependencies seems to work.

@theimowski
Copy link
Member

This looks good now - let me first fix the Travis build and then rerun this PR to see all works as expected

@theimowski
Copy link
Member

I decided to remove the if condition for package.json - it adds another layer of complexity and makes it hard to update package.json.lock and yarn.lock.
Also had to update terser package to 4.0.2 due to a known bug

@theimowski
Copy link
Member

The change results in following warnings:

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  b22164d568f72650d592271d22dd5cda.svg (259 KiB)
  fedf49d31f55f4beaf2c891f3875554f.svg (265 KiB)
  bf4dde0147bb02556500d922e2efc90b.svg (267 KiB)
  a33a878f3861ca67e9bc423c58b2a357.svg (285 KiB)
  2a9a30e14574c9ec24add2901a80b81c.svg (292 KiB)
  336bcb7b78f6c5e55120951f0045a8d8.svg (292 KiB)
  a84e8591bb7eb3998ad492c27c4c3d52.svg (284 KiB)
  b46ff9f5c8bcba1ea3b4b320e22be5c7.svg (290 KiB)
  073c2f3ce60eaf69cc2767ef3d989078.svg (674 KiB)
  b557f56e367e59344ca95f9d1fb44352.svg (820 KiB)
  24aab533f87e7b434be5fa5b1684975c.svg (1.13 MiB)
  f108c981ed9611d5cc44f688b9ce80a4.svg (1.13 MiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  app (514 KiB)
      vendors~app.0dae4e752fada070d504.js
      style.0dae4e752fada070d504.css
      app.0dae4e752fada070d504.js

Anyone knows what the SVG files are for?
And do I understand correctly that we shouldn't worry about the entrypoint size limit increase, because the browser needs to download the css from CDN anyway?

Related issue: #185

@theimowski theimowski merged commit 7e3abbd into SAFE-Stack:master Jul 5, 2019
@theimowski
Copy link
Member

Thanks! released in v1.11

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.

3 participants