Adding LostGrid to Ruby on Rails with webpack - ruby-on-rails

First poster here.
I just created a new Rails project with webpack (rails new myapp --webpack). It comes with PostCSS and I wanted to add LostGrid to it. I ran the following, from the installation instructions from Lost:
npm install --save lost
This added Lost to package.json. The instructions then say to add the following to your webpack config, assuming you have postcss-loader installed & configured (which I understand was installed automatically when the project was created):
postcss: [
require('lost')
]
But I don't understand where the file is. I thought that I needed to add my PostCSS stuff to .postcssrc.yml in the root. I did this but I still don't get it to work.
I have very little experience with webpack and suspect that my approach is entirely flawed. I was excited to use PostCSS in Rails and would appreciate any help in getting to make LostGrid work here. Thanks!

Found your question moments after I ran into the same issue. Fortunately it's really simple!
When you run webpacker:install it installs a file called .postcssrc.yml in the root folder of the project. This is where you add thePostCSS plugins. Mine now looks like this:
plugins:
lost: {}
postcss-smart-import: {}
postcss-cssnext: {}
autoprefixer: {}
I am not sure yet whether the order matters. Still researching that.
See Webpacker issue #283 which is essentially the same question, but without an example provided.

Related

Is there a way to integrate Material-components-web in ASP.NET MVC

I'm trying to integrate material-components-web from Material.io. But it turned out to be quite a hassle. I'm also very new to the Node world, so i'm learning as i try a long.
This is what i did so far:
Coupled NPM to Visual Studio 2017, I can use a lot of functionalities, but it doesn't really work like i imagined. Npm init for example hangs, but install/update commands work fine.
Got a Packag.json with the following dependencies:
"devDependencies": {
"material-components-web": "0.44.1",
"gulp": "3.9.1",
"gulp-util": "3.0.8",
"gulp-minify-css": "1.2.4",
"gulp-path": "4.0.0",
"gulp-js-minify": "0.0.3",
"gulp-sass": "3.1.0",
"gulp-flatten": "0.4.0"
}
Installed Gulp and set up my Sass compiler and css/js minifier(for production). And set them up to run before i build my project
I have my #material folder with all the basic components in it. But now i'm running into the problem of the Javascript module dependencies.
I noticed that the standard 'require' methods where not working because it it a node specific resolver (Correct me if I'm wrong). First I tried to integrate Babel in gulp to transform the imports to ECMA. But that seemed unsuccessful.
Now i am converting all the import/exports by hand (so updating is a no go). It started out working great. But now i'm getting tangled up in dependencies hell, with references and imports all over the place... From dependencies like (focus-trap.js, tabbale and xtend)
Is this even possible to integrate in ASP.NET MVC? I also noticed that Material-components-web is starting to switch to TypeScript on their github!
Any tips or help are really appreciated.
I ended up doing the following to be able to use material-components-web for the front-end:
Downloaded Node.Js and added the NPM location as a 3rd party reference to Visual studio 2017.
Added the node_modules folder to my project and ran npm-install
Copied all the dependencies (Except 'Babel' the transpiler). And installed them with NPM
Created a WebPack config for compilation, extraction etc. etc.
It was actually pretty basic, but without any knowledge and information to use this type of NPM packages in an older MVC project was quite a big hassle to find out.
If somebody needs more informations or help, just comment below.

Webpacker creates huge node_modules

I created a new project with Rails 5.1 and I want to use webpacker to manage my react dependencies. The problem is after installing webpacker it creates a huge 130Mb+ dir node_modules with every possible node_package. This does not make sense as default behavior. How can I configure Webpacker to only keep the packages I'm actually using. I have searched for this issue in every way I could and I did not see any answers that made sense
Install what you need via yarn add, they will be listed in your package.json. Once you run assets:precompile (which will also run webpacker:compile) or just webpacker:compile, the public folder will be populated the compiled assets you are going to need to run the app.
Like Tamer says, node_modules should be in your .gitignore file. In dev, you will see all the node modules due to existing dependencies but that doesn't mean they are going to be used.
In summary, don't worry and rely on yarn.

Cannot use node-hid library in electron app

I had integrated OpenTok.js library for video call in my electron app, for which i want to use logitech device and to use it i need node-hid library using which my app can detect device.
I had done all the needful mentioned for using node-hid in Electron projects, package did get installed
but when i require it in my js file using :-
var HID = require('node-hid');
var devices = HID.devices();
And run my app , it gives an error
Error: Module version mismatch. Expected 50, got 51. So please help me
with this issue .
Thanks
Use electron-rebuild for rebuild modules for suitable for electron. Some node modules are not exactly suitable for electron, because electron uses it's own build of Node. So, electron-rebuild will sort out any incompatibility or functional issues of node modules we use. The recommended way it to add "postinstall": "electron-rebuild --force" line to scripts of package.json file.
One other thing, on linux when you run dev mode, you have to run the script as sudo. Otherwise it'll rise another issue like cannot open device with path...
hope this help someone... :)
I encountered this issue myself, and thought I would share the solution that worked for me. #Tharanga is correct - the recommended way to get around this is to include the below in package.json "scripts" section:
"postinstall": "electron-rebuild --force"
However, I have experienced inconsistent success with that approach.
Another approach is, after installing "node-hid", run this (if on mac):
.\node_modules\.bin\electron-rebuild
Or for Windows:
.\node_modules\.bin\electron-rebuild.cmd
Finally, if you are using webpack in your project, you must add this line to your webpack.config.js file (within module.exports block):
externals: {
"node-hid" : 'commonjs node-hid'
}
I hope this helps some folks in the future!

Apigility Admin UI Not Opening

so my apigility admin area was working just fine before they updated it to ZF3.
No after composer update, I am getting this when I try to open /apigility/ui
Does anyone know what might be the problem and how can we resolve this issue ?
The Issue is:
In the error logs you'll find that css and js data is not loaded. As the rwoverdijk/assetmanager is removed since apigility Admin 1.5 some files are not loaded anymore.
Solution:
Follow part 2. of the Upgrade from https://github.com/zfcampus/zf-apigility-admin#initial-upgrade-to-15
I also tried part 1 what was also working because now the rwoverdijk/assetmanager is now on 1.7.1 (but i do not know if the incompatibility is solved with this version so i did it with the zfcampus/zf-asset-manager). I'm still on ZF2 but the issue is the same.
Install zf-asset-manager. This is a Composer plugin, and operates when installing or uninstalling a package. If you add this, you will need to follow these steps:
composer require --dev zfcampus/zf-asset-manager
rm -Rf ./vendor
composer install
The additional steps are necessary in order for the plugin to pick up on the assets from the other components and copy them to the public folder. After installation you ll find a folder apigility-ui in you
Something similar happened to me when I reused the same code for a new repository on my local development environment having set the base_path value on
./module/Application/config/module.config.php.
'view_manager' => [
'base_path' => 'https://subdomain1.example.com',..]
I solved it by deleting the base_path config value.
The view cannot be rendered fully as the wrong html base is injected to the rendered view. In my case the html base looked like
<base href="http://subdomain2.example.com.devhttps://subdomain1.example.com/">
Instead of
<base href="http://subdomain2.example.com.dev">

Bower not copying any files

Im using bower as part of the yeoman 1.0 beta 4 install. All looks well however when I run bower install I get the expected output yet no files are copied to app/components as advertised.
I am running on windows which I understand is not officially supported yet. Has any one managed to get this up and running with some success? I have followed some tutorials on line relating to the subject however I think they are out dated. I managed to install yeoman without any additional steps and no errors as far as I can tell.
Grunt File being Used
Oh no... Git was not on the system path. Adding it caused me to run into another small error with a solution found here http://wingkaiwan.com/2012/11/25/bower-errors-on-windows/
Thank you Mr Ricky Wan

Resources