onkara
Hi guys
I am running into issues integrating tailwind css into my Phoenix/LV project the error seems related to webpack-cli specially around asset watchers. I know its not directly related to Phoenix/LV issue, but could anyone shed some light on it. Thanks.
here is the stack trace
10:13a ~/P/l ✨main* ➤ iex -S mix phx.server
Erlang/OTP 23 [erts-11.1.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
[info] Running LPWeb.Endpoint with cowboy 2.8.0 at 0.0.0.0:4000 (http)
[info] Access LPWeb.Endpoint at http://localhost:4000
Interactive Elixir (1.11.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> [webpack-cli] TypeError: Cannot read property 'name' of undefined
at new WebpackCLI (/home/onkara/Projects/LP/assets/node_modules/webpack-cli/lib/webpack-cli.js:22:22)
at runCLI (/home/onkara/Projects/LP/assets/node_modules/webpack-cli/lib/bootstrap.js:9:21)
at Object.<anonymous> (/home/onkara/Projects/LP/assets/node_modules/webpack-cli/bin/cli.js:22:5)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (node:internal/modules/cjs/helpers:92:18)
at runCli (/home/onkara/Projects/LP/assets/node_modules/webpack/bin/webpack.js:54:2)
[error] Task #PID<0.577.0> started from LPWeb.Endpoint terminating
** (stop) :watcher_command_error
(phoenix 1.5.7) lib/phoenix/endpoint/watcher.ex:37: Phoenix.Endpoint.Watcher.watch/3
(elixir 1.11.2) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/3
Args: ["node", ["node_modules/webpack/bin/webpack.js", "--mode", "development", "--watch"], [cd: "/home/onkara/Projects/LP/assets"]]
here is the webpack.config.js
const path = require('path');
const glob = require('glob');
// const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env, options) => {
const devMode = options.mode !== 'production';
return {
optimization: {
minimizer: [
new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }),
new CssMinimizerPlugin({})
]
},
entry: {
'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, '../priv/static/js'),
publicPath: '/js/'
},
devtool: devMode ? 'eval-cheap-module-source-map' : undefined,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.[s]?css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader',
],
}
]
},
plugins: [
new MiniCssExtractPlugin({ filename: '../css/app.css' }),
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
]
// .concat(devMode ? [new HardSourceWebpackPlugin()] : [])
}
};
here is the package.json
{
"repository": {},
"description": " ",
"license": "MIT",
"scripts": {
"deploy": "NODE_ENV=production webpack --mode production",
"watch": "webpack --mode development --watch"
},
"dependencies": {
"alpinejs": "^2.7.3",
"kutty": "^0.4.1",
"nprogress": "^0.2.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"tailwindcss": "^2.0.1",
"yarn": "^1.22.10"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"autoprefixer": "^10.0.4",
"babel-loader": "^8.0.0",
"copy-webpack-plugin": "^5.1.2",
"css-loader": "^5.0.1",
"css-minimizer-webpack-plugin": "^1.2.0",
"hard-source-webpack-plugin": "^0.13.1",
"mini-css-extract-plugin": "^1.3.3",
"postcss": "^8.2.4",
"postcss-loader": "^4.2.0",
"sass": "^1.17.1",
"sass-loader": "^10.1.0",
"terser-webpack-plugin": "^2.3.2",
"webpack": "^5.19.0",
"webpack-cli": "^4.4.0"
}
}
here is the config in dev.exs
config :LP, LPWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch",
cd: Path.expand("../assets", __DIR__)
]
]
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
There are some mistakes…
should be
This is not the latest, but if You update You will need to change config
should be
Try updating, and see if there are more errors.
onkara
Thanks for your reply. It helped a lot.
I made the above mentioned changes and also changes to CopyWebPackPlugin config
with this in
webpack.config.jsthen I got this error
my app.scss looks this
So I added
"postcss-import": "^14.0",topackage.jsonand I no longer got those errors and I have both tailwindcss and regular css working together.Once again thanks a lot.
overcomeoj
Seems you sorted your issue, but for others who might need a guide, I followed this: Adding Tailwind CSS to Phoenix 1.6 a few days ago and had no trouble getting everything to click together.