webpacker | Use Webpack to manage app-like JavaScript modules in Rails | Plugin library
kandi X-RAY | webpacker Summary
kandi X-RAY | webpacker Summary
Webpacker makes it easy to use the JavaScript pre-processor and bundler Webpack v5 to manage application-like JavaScript in Rails. It can coexist with the asset pipeline, leaving Webpack responsible solely for app-like JavaScript, or it can be used exclusively, making it also responsible for images, fronts, and CSS. NOTE: The master branch now hosts the code for v6.x.x. Please refer to 5-x-stable branch for 5.x documentation.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Run the application .
- Execute the webkit command
- Load the config file
- Checks if the command is installed .
- Initialize a new port .
- Run the command .
- Checks if the node exists .
webpacker Key Features
webpacker Examples and Code Snippets
$yarn add jquery
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery:
yarn add jquery
yarn add bootstrap@next
yarn add @popperjs/core
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePl
$ yarn add jquery
$ yarn add dayjs
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jque
gem "webpacker", github: "rails/webpacker", ref: 'b6c2180'
npm uninstall webpack -g
yarn remove @rails/webpacker
yarn add rails/webpacker#b6c2180
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
"style-loader",
"css-loader",
{
loader: "sass-loader",
options: {
// config/webpack/base.js
const { webpackConfig, merge } = require('@rails/webpacker')
const customConfig = require('./custom')
module.exports = merge(webpackConfig, customConfig)
// config/webpack/custom.js
con
const { environment } = require('@rails/webpacker')
const { merge } = require('webpack-merge');
const sassLoader = environment.loaders.get('sass')
const cssLoader = environment.loaders.get('css')
sassLoader.use.map(loader => {
if (
// Conflict somehow
window.bootstrap = require('bootstrap/dist/js/bootstrap.bundle.js')
const bootstrap = require('bootstrap') // or
import bootstrap from 'bootstrap'
// config/webpack/envi
// /config/webpack/environment.js
const { environment } = require('@rails/webpacker')
environment.config.merge({
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto"
const { environment } = require('@rails/webpacker')
const globImporter = require('node-sass-glob-importer');
environment
.loaders
.get('sass')
.use
.find(item => item.loader === 'sass-loader')
.options = { sassOpti
Community Discussions
Trending Discussions on webpacker
QUESTION
I'm making simple CRUD and the current goal is to add data. However, I found that I can't add any data, and the terminal log also shows "[Webpacker] Everything's up-to-date. Nothing to do", which means there is no error message.
According to my design in the controller, the new data must have failed, so I stopped at new.html.erb. I'm guessing it has something to do with the model's relationship.
This is model User
...ANSWER
Answered 2022-Apr-17 at 10:03You are probably right that it is a validation error related to the belongs_to relationship. You should display validation errors for your form as described here https://guides.rubyonrails.org/getting_started.html#validations-and-displaying-error-messages
QUESTION
I'm trying to use npm package 'tailwindcss-flip' in my Rails 7 app. The package docs have the following instructions:
Install tailwindcss-flip package:
Install using NPM
npm install tailwindcss-flip --save-dev
Install using Yarn
yarn add tailwindcss-flip --dev
Add plugin to your tailwind.conf.js file:
plugins: [require("tailwindcss-flip")]
My question is, I did pin the package in importmap, but I got the following error:
...ANSWER
Answered 2022-Mar-31 at 08:51I assume you're using tailwindcss-rails
gem. That is the default even if you run rails new app --css tailwind
. It uses standalone tailwind executable https://tailwindcss.com/blog/standalone-cli which comes bundled with first party plugins. So any plugin in @tailswindcss/*
should work out of the box.
To use any other tailwind plugins you must run a full node.js version of tailwind. The Rails 7 way is to use cssbundling-rails
.
QUESTION
I updated from ruby 2.7.1 to 3.1.1, then removed Gemfile.lock and ran bundle update
(it's on a dev branch, so I can throw it away if this is a bad idea, I just wanted to see if it would work).
bundle update
succeeds, but when I start the server:
ANSWER
Answered 2022-Mar-19 at 10:21The problem is related to the Ruby 3.1 / Psych 4.x incompatibility described in this issue: https://bugs.ruby-lang.org/issues/17866
Ruby 3.0 comes with Psych 3, while Ruby 3.1 comes with Psych 4, which has a major breaking change (diff 3.3.2 → 4.0.0).
- The new YAML loading methods (Psych 4) do not load aliases unless they get the
aliases: true
argument. - The old YAML loading methods (Psych 3) do not support the
aliases
keyword.
At this point, it seems like anyone, anywhere that wants to load YAML in the same way it worked prior to Ruby 3.1, need to do something like this:
QUESTION
I'm running into an error on Windows 10 whenever I try to run webpack, it works fine on macOS. This is the error
[webpack-cli] HookWebpackError: Not supported
It runs fine without "CopyPlugin", but I would like to copy img folder into dist folder. Have you experienced similar issues and how did you fix them?
...ANSWER
Answered 2022-Mar-02 at 02:37Your node version is lower than 12.20,Please select one of the schemes
1.Upgrade your node
npm install node@12.20.0 -g
Or the latest
npm install node@latest -g
Under Windows npm install node
may note work, and you should install the latest from https://nodejs.org/en/download/ using Windows Installer (.msi)
2.Reduce the version of copy-webpack-plugin
npm install copy-webpack-plugin@9 -D
QUESTION
After upgrading from webpacker version 4 to version 5.3.4, I am seeing the following error.
...ANSWER
Answered 2022-Feb-16 at 00:41The upgrade to version 5 of webpacker
made some breaking changes, including how to specify the loading of scss and scss files in ruby on rails apps. Previously in application.js
I had
QUESTION
ANSWER
Answered 2022-Feb-10 at 06:53yes, my webpacker is running well. differing from above, my settings are:
config/webpack/environment.js like above, but without the line "poper".
packs/application.js
QUESTION
I am learning Hotwire-rails, following both the gorails.com and the Hotwire.dev examples. I am running Ruby 3.0.2 and Rails 6.1.4.1. The symptom is at the very start. After rails new xxx, I edit Gemfile to add gem 'hotwire-rails', then bundle install. At this point my app/javascript/packs/application.js is now:
...ANSWER
Answered 2021-Nov-11 at 12:27This seems like everything is working correctly rails just likes to output what its doing to the console but it should have added those to your file.
QUESTION
I have this in my application.scss, but I don't understand how it works:
...ANSWER
Answered 2022-Feb-05 at 11:14It's sprockets directive
Sprockets is a gem for assets compiling
So there are few directives with such syntax
//= require
- Add the contents of a file to current
//= require_self
- Change order of where current contents are concatenated to current
//= require_directory
- Add contents of each file in a folder to current
//= require_tree
- Add contents of all files in all directories in a path to current
//= link
- Make target file compile and be publicly available without adding contents to current
//= link_directory
- Make target directory compile and be publicly available without adding contents to current
//= link_tree
- Make target tree compile and be publicly available without adding contents to current
//= depend_on
- Recompile current file if target has changed
//= stub
- Ignore target file
These directives are parsed with Sprockets::DirectiveProcessor
entity
And about how it works with other libraries
There is config.assets.paths
in the app when you use sprockets. So sprockets search assets there. For example in node_modules
folder. It looks that you install bootstrap using yarn and this style sheets are in that directory
But if you install with gem, this gem add to config.assets.paths
its own paths
QUESTION
I'm trying to create a rails app by installing bootstrap and jQuery. First I tried to create using
...ANSWER
Answered 2022-Jan-31 at 11:51And also tried to install by using
QUESTION
I just upgraded to Angular 13 from Angular 12 and also updated some other NPM packages.
One of them contained scss files that are referenced in my angular.json file. This was never a problem, but after trying to serve my application I get an error message that is hard to understand for me:
ANSWER
Answered 2022-Jan-12 at 03:21It was because of a cached version of node-sass.You can try this.
- Remove the node-sass from global npm-cache(For Windows users %userprofile%\AppData\Roaming\npm-cache).
- Remove node-sass from your project's node_modules dir.
- Do npm install to reinstall node-sass.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install webpacker
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page