Webpack has been initialised using a configuration object that does not match the API schema


#1

When I do a webpacker:compile or jets deploy I get the below error
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration.entry should be one of these:
    object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function
    -> The entry point(s) of the compilation.
    Details:
    • configuration.entry should not be empty.
      -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.
    • configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    • configuration.entry should be an array:
      [non-empty string]
    • configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.
      JETS_ENV=production /Users/zee/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bin/webpack failed to run.

package.json:

{
“scripts”: {
“start:webpack”: "node_modules/.bin/webpack-dev-server node_modules/webpack-dev-server/client/webpack.config.js ",
“start:dev”: “webpack-dev-server”
},
“dependencies”: {
@rails/webpacker”: “^3.5.5”,
“bootstrap”: “4.0.0-beta”,
“coffeescript”: “1.12.7”,
“jquery”: “^3.3.1”,
“popper.js”: “^1.14.7”
},
“devDependencies”: {
“webpack-dev-server”: “^3.2.1”
}
}

gemfile
gem “jets”
gem “webpacker”, git: “https://github.com/tongueroo/webpacker.git”, branch: “jets”
gem “mysql2”, “~> 0.5.2”
gem “dynomite”
group :development, :test do
gem ‘byebug’, platforms: [:mri, :mingw, :x64_mingw]
gem ‘shotgun’
gem ‘rack’
end

group :test do
gem ‘rspec’
gem ‘launchy’
gem ‘capybara’
end

webpacker.yml

default: &default
source_path: app/webpack
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
resolved_paths: []
cache_manifest: false

extensions:
- .coffee
- .erb
- .js
- .jsx
- .ts
- .vue
- .sass
- .scss
- .css
- .png
- .svg
- .gif
- .jpeg
- .jpg

development:
<<: *default
compile: true

dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
‘Access-Control-Allow-Origin’: ‘*’
watch_options:
ignored: /node_modules/
test:
<<: *default
compile: true
public_output_path: packs-test
staging:
<<: *default
compile: false
cache_manifest: true
production:
<<: *default
compile: false
cache_manifest: true


#2

Solved this myself. The error is very not descriptive of the actual issue.
The app/webpack/packs directory needed to have an application.js file with the following lines
import ‘…/src/jets/crud’
which is the standard file which I deleted thinking it would be ok. Its not ok!

In my app the folder is app/webpack/packs but in the standard jets project its app/javascript/packs
make sure your webpack.yml nominates the correct source directory, if you change this