Giter Club home page Giter Club logo

webpack-rails's Introduction

No Longer Maintained

Hi! webpack-rails is no longer being maintained. Please see #90 for more info.

Build Status Gem Version

webpack-rails

webpack-rails gives you tools to integrate Webpack in to an existing Ruby on Rails application.

It will happily co-exist with sprockets but does not use it for production fingerprinting or asset serving. webpack-rails is designed with the assumption that if you're using Webpack you treat Javascript as a first-class citizen. This means that you control the webpack config, package.json, and use yarn to install Webpack & its plugins.

In development mode webpack-dev-server is used to serve webpacked entry points and offer hot module reloading. In production entry points are built in to public/webpack. webpack-rails uses stats-webpack-plugin to translate entry points in to asset paths.

It was designed for use at Marketplacer to assist us in migrating our Javascript (and possibly our SCSS) off of Sprockets. It first saw production use in June 2015.

Our examples show webpack-rails co-existing with sprockets (as that's how environment works), but sprockets is not used or required for development or production use of this gem.

This gem has been tested against Rails 4.2 and Ruby 2.2. Earlier versions of Rails (>= 3.2) and Ruby (>= 2.0) may work, but we haven't tested them.

Using webpack-rails

We have a demo application: webpack-rails-demo

Installation

  1. Install yarn if you haven't already
  2. Add webpack-rails to your gemfile
  3. Run bundle install to install the gem
  4. Run bundle exec rails generate webpack_rails:install to copy across example files
  5. Run foreman start to start webpack-dev-server and rails server at the same time
  6. Add the webpack entry point to your layout (see next section)
  7. Edit webpack/application.js and write some code

Adding the entry point to your Rails application

To add your webpacked javascript in to your app, add the following to the <head> section of your to your layout.html.erb:

<%= javascript_include_tag *webpack_asset_paths("application") %>

Take note of the splat (*): webpack_asset_paths returns an array, as one entry point can map to multiple paths, especially if hot reloading is enabled in Webpack.

If your webpack is configured to output both CSS and JS, you can use the extension: argument to filter which files are returned by the helper:

<%= javascript_include_tag *webpack_asset_paths('application', extension: 'js') %>
<%= stylesheet_link_tag *webpack_asset_paths('application', extension: 'css') %>

Use with webpack-dev-server live reload

If you're using the webpack dev server's live reload feature (not the React hot reloader), you'll also need to include the following in your layout template:

<script src="http://localhost:3808/webpack-dev-server.js"></script>

How it works

Have a look at the files in the examples directory. Of note:

  • We use foreman and a Procfile to run our rails server & the webpack dev server in development at the same time
  • The webpack and gem configuration must be in sync - look at our railtie for configuration options
  • We require that stats-webpack-plugin is loaded to automatically generate a production manifest & resolve paths during development

Configuration Defaults

  • Webpack configuration lives in config/webpack.config.js
  • Webpack & Webpack Dev Server binaries are in node_modules/.bin/
  • Webpack Dev Server will run on port 3808 on localhost via HTTP
  • Webpack Dev Server is enabled in development & test, but not in production
  • Webpacked assets will be compiled to public/webpack
  • The manifest file is named manifest.json

Dynamic host

To have the host evaluated at request-time, set host to a proc:

config.webpack.dev_server.host = proc { request.host }

This is useful when accessing your Rails app over the network (remember to bind both your Rails app and your WebPack server to 0.0.0.0).

Use with docker-compose

If you're running webpack-dev-server as part of docker compose rather than foreman, you might find that the host and port that rails needs to use to retrieve the manifest isn't the same as the host and port that you'll be giving to the browser to retrieve the assets.

If so, you can set the manifest_host and manifest_port away from their default of localhost and port 3808.

Working with browser tests

In development, we make sure that the webpack-dev-server is running when browser tests are running.

Continuous Integration

In CI, we manually run webpack to compile the assets to public and set config.webpack.dev_server.enabled to false in our config/environments/test.rb:

config.webpack.dev_server.enabled = !ENV['CI']

Production Deployment

Add rake webpack:compile to your deployment. It serves a similar purpose as Sprockets' assets:precompile task. If you're using Webpack and Sprockets (as we are at Marketplacer) you'll need to run both tasks - but it doesn't matter which order they're run in.

If you deploy to Heroku, you can add the special webpack-rails-buildpack in order to perform this rake task on each deployment.

If you're using [chunkhash] in your build asset filenames (which you should be, if you want to cache them in production), you'll need to persist built assets between deployments. Consider in-flight requests at the time of deployment: they'll receive paths based on the old manifest.json, not the new one.

TODO

  • Drive config via JSON, have webpack.config.js read same JSON?
  • Custom webpack-dev-server that exposes errors, stats, etc
  • react-rails fork for use with this workflow
  • Integration tests

Contributing

Pull requests & issues welcome. Advice & criticism regarding webpack config approach also welcome.

Please ensure that pull requests pass both rubocop & rspec. New functionality should be discussed in an issue first.

Acknowledgements

webpack-rails's People

Contributors

agis avatar alexkrolick avatar ares avatar febeling avatar hfwang avatar hotgazpacho avatar kommen avatar lordmortis avatar mattgibson avatar mikeauclair avatar mipearson avatar thiagoa avatar twojustin avatar zinssmeister avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webpack-rails's Issues

Lack of development value breaks production

When using webpack to generate assets server side, e.g. PDF, the dev_server.host is not set. Is there a reason why the host calculation below is not inside the dev_server.enabled check?

host = ::Rails.configuration.webpack.dev_server.host
host = instance_eval(&host) if host.respond_to?(:call)

if ::Rails.configuration.webpack.dev_server.enabled
  paths.map! do |p|
    "#{protocol}://#{host}:#{port}#{p}"
  end
end

paths

Ref: https://github.com/mipearson/webpack-rails/blob/master/lib/webpack/rails/helper.rb#L24-L33

Cannot use --lazy option on webpack-dev-server

Passing the --lazy flag to webpack-dev-server causes unexpected token at 'Cannot GET /webpack/manifest.json exception.

I've tried using the workarounds suggested in #58 just in case it was related, but it still breaks. You can reproduce this issue easily by adding the --lazy flag to the webpack command in the Procfile of https://github.com/mipearson/webpack-rails-demo

Is it possible for webpack-rails to support this functionality? If not, perhaps its worth documenting.

Ngrok Support

Hi there! I'm trying to get ngrok working with this, so that I can test out my app on my phone.
So I changed my webpack.config.js to look like this

  config.devServer = {
    host: '0.0.0.0',
    port: devServerPort,
    headers: { 'Access-Control-Allow-Origin': '*' }
  };
  if (process.env.NGROK) {
    config.output.publicPath = process.env.NGROK + '/webpack/';
  } else {
    config.output.publicPath = '//localhost:' + devServerPort + '/webpack/';
  }

And then I changed my config/webpack.rb to look like this

if ENV['NGROK'].present?
  Rails.configuration.webpack.dev_server.host = ENV['NGROK']
  Rails.configuration.webpack.dev_server.port = '';
  Rails.configuration.webpack.dev_server.manifest_host = ENV['NGROK']
  Rails.configuration.webpack.dev_server.manifest_port = '';
end

And I'm running it like this NGROK=custom-webpack-domain.ngrok.io foreman start

But I ran into an issue. The port is being set, even when I set it to '', which means that my url comes out looking like http://custom-webpack-domain.ngrok.io:/webpack/manifest.json. That pesky colon is messing everything up. I think we can pretty easily fix this so that the port isn't used it you set it to empty string or nil. What do you think? I'd be glad to do the work and submit a pull request, but honestly I've never done any development on gems before, so I'm not sure how I'd do it. I think this is a pretty simple fix, which shouldn't take more than 15 mins to get right.

React jsx doesn't compile

Have a problem with compiling jsx files in my rails app.

What I have?

Gemfile

gem 'react-rails'
gem 'webpack-rails'

package.json

{
  "name": "webpack-rails-example",
  "version": "0.0.1",
  "license": "MIT",
  "dependencies": {
    "stats-webpack-plugin": "^0.2.1",
    "webpack": "^1.9.11",
    "webpack-dev-server": "^1.9.0",
    "react": "0.14.8",
    "react-dom": "latest",
    "react-redux": "latest",
    "babel-loader": "^6.0.1",
    "babel-core": "latest",
    "babel-preset-es2015": "^6.0.15",
    "babel-preset-react": "^6.0.15"
  }
}

webpack/components/result.js.jsx

import React, { Component, PropTypes } from 'react';

class UpdateResult extends Component {
  ...
  render() {
    const { updateResult, result, district } = this.props;
    return (
        <div>
        sss
        </div>
        )
    ;
  }
}

export default UpdateResult;

webpack/application.js

window.UpdateResult = require('components/result.jsx.js').default

app/views/show.html.slim

= react_component('UpdateResult')

*config/webpack.config.js

...
  module: {
    loaders: [
    {
      test: /\.js$/,
      loader: 'babel-loader',
      exclude: /node_modules/
    }
    ]
...

*.babelrc

{
  "presets": ["es2015", "stage-0","stage-2", "react"],
  "plugins": ["transform-react-jsx"]
}

I'm new on this stack. Pls, help.

How the hell should dev server hosts work?

Hi @bradfeehan @mattgibson @hotgazpacho @Aupajo @kagux

I don't use docker or virtual machines in my local development environment, so I think I've missed a use case when designing how Rails will retrieve the manifest file and how the assets will be communicated to the user.

The intention was that, despite what dev_server.host is set to, the webpack-dev-server would always be running on the same machine as the Rails server, via the Procfile. Thus, it'd always be available via localhost on the configured port. Obviously this is not always the case. Have I misunderstood something about how docker works?

Given the PRs that have been submitted I'm considering a mix of #28 (in fact, making request.host the default) and #23, but I'm worried that this will make things too complicated and hinder future development & use.

I'm hoping that you can outline how you're using webpack-rails and how the current setup isn't working, so that we can agree on a universal & simple way forward.

[feature request] only keep last n built assets

First of all, I love this gem, it helps me to integrate webpack with rails without pain. With a little customization it works so great in both environment.

One thing I think it's missing is that it can't preserve last n builds between deployments like sprockets-rails does. I think it's essential because we not only want to keep assets during deployment, but remove older ones to not eat up our disk.

Public path is hard-coded as localhost

This isn't necessarily a bug, but it's potentially confusing. When you start the server with the default config/webpack.config.js, it prints:

 webpack result is served from //localhost:3808/webpack/

While this is true in the default case, if you start it with a custom host binding, like this:

webpack-dev-server --config config/webpack.config.js --host 10.0.0.100

Then the hard-coded localhost is a bit misleading. Since webpack-dev-server already prints the host and port binding on the line immediately prior, it might make sense to just limit the publicPath setting to the actual file path (/webpack). For example:

 http://10.0.0.100:3808/webpack-dev-server/
webpack result is served from /webpack/

In reading the webpack-dev-server documentation, it looks like publicPath is supposed to be relative, but I'm still learning, so I'm not sure, but it works for me with just the relative path setting.

question: cucumber usage with webpack-rails + phantomjs/poltergeist

This doesn't in any way appear to be a problem with webpack-rails, but I figured this is the best place to ask this question.

I'm curious if anyone else has had problems getting cucumber features to work with a webpack-rails setup when using the webpack dev server?

  • When I build/transpile webpack upfront and execute cucumber, all is well (including screenshots).
  • When I use the webpack dev server and execute cucumber all fails (including screenshots, they are empty)

Here is my cucumber setup

I tried making my capybara wait time high but that seemed not to make a difference. I also examined the poltergeist network traffic and it seems to be successfully communicating with the webpack dev server:

{
    "data": {
      "headers": [
        {
          "name": "Accept",
          "value": "*/*"
        },
        {
          "name": "Referer",
          "value": "http://dummy.com.127.0.0.1.xip.io:9896/"
        },
        {
          "name": "User-Agent",
          "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"
        }
      ],
      "id": 4,
      "method": "GET",
      "time": "2016-11-10T21:43:14.685Z",
      "url": "http://public.dummy.com.127.0.0.1.xip.io:3808/webpack/application.js"
    },
    "response_parts": [
      {
        "data": {
          "body": "",
          "bodySize": 392056,
          "contentType": "application/javascript; charset=UTF-8",
          "headers": [
            {
              "name": "X-Powered-By",
              "value": "Express"
            },
            {
              "name": "Access-Control-Allow-Origin",
              "value": "*"
            },
            {
              "name": "Accept-Ranges",
              "value": "bytes"
            },
            {
              "name": "Content-Type",
              "value": "application/javascript; charset=UTF-8"
            },
            {
              "name": "Content-Length",
              "value": "4770753"
            },
            {
              "name": "ETag",
              "value": "W/\"48cbc1-naaAJKiGSfvZdEC09GTdEg\""
            },
            {
              "name": "Date",
              "value": "Thu, 10 Nov 2016 21:43:14 GMT"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            }
          ],
          "id": 4,
          "redirectURL": null,
          "stage": "start",
          "status": 200,
          "statusText": "OK",
          "time": "2016-11-10T21:43:14.695Z",
          "url": "http://public.dummy.com.127.0.0.1.xip.io:3808/webpack/application.js"
        }
      },
      {
        "data": {
          "contentType": "application/javascript; charset=UTF-8",
          "headers": [
            {
              "name": "X-Powered-By",
              "value": "Express"
            },
            {
              "name": "Access-Control-Allow-Origin",
              "value": "*"
            },
            {
              "name": "Accept-Ranges",
              "value": "bytes"
            },
            {
              "name": "Content-Type",
              "value": "application/javascript; charset=UTF-8"
            },
            {
              "name": "Content-Length",
              "value": "4770753"
            },
            {
              "name": "ETag",
              "value": "W/\"48cbc1-naaAJKiGSfvZdEC09GTdEg\""
            },
            {
              "name": "Date",
              "value": "Thu, 10 Nov 2016 21:43:14 GMT"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            }
          ],
          "id": 4,
          "redirectURL": null,
          "stage": "end",
          "status": 200,
          "statusText": "OK",
          "time": "2016-11-10T21:43:14.699Z",
          "url": "http://public.dummy.com.127.0.0.1.xip.io:3808/webpack/application.js"
        }
      }
    ],
    "error": null
  }

And the console looks good from the browser:

[HMR] Waiting for update signal from WDS...
[HMR] Waiting for update signal from WDS...

Any thoughts?

not working on production

Hello @mipearson thanks for your great work! I've used this gem and webpack is working great with rails on local.

However I deployed app to AWS opswork and did rake webpack:compile, I get this error.
#2432 ActionView::Template::Error: Could not load manifest from webpack-dev-server at http://localhost:3808/webpack/manifest.json - is it running, and is stats-webpack-plugin loaded? (original error Connection refused - connect(2) for "localhost" port 3808)

We're not accessing localhost:3808 on production right? Do you have any idea why I got this error?

Thanks.

Using on CI

In CI, we manually run webpack to compile the assets to public and set config.webpack.dev_server.enabled to false. - How do you set that config on your CI/which CI do you use?

Gem 0.9.4 is missing examples

Seems like latest gem version of webpack-rails (0.9.4) is missing examples folder and so bundle exec rails generate webpack_rails:install errors out.

unexpected token at 'Cannot GET /webpack/manifest.json

Hello,

I have a problem with this gem. I have created a simple project to test webpack-rails with a controller and a unique view. When i execute foreman start I get the following error: "unexpected token at 'Cannot GET /webpack/manifest.json"

I have:

  • Ruby 2.3.0
  • Rails 5.0
  • Node 6.6.0

I followed the installation instructions:

-Add webpack-rails to your gemfile
-Run bundle install to install the gem
-Run bundle exec rails generate webpack_rails:install to copy across example files
-Run foreman start to start webpack-dev-server and rails server at the same time
-Add the webpack entry point to your layout (see next section)
-Edit webpack/application.js and write some code

I have added "<%= javascript_include_tag *webpack_asset_paths("application") %>" to the layout.html.erb

¿Any solution?

Thanks!!

Accessing assets from the asset pipeline

I've got some image paths that I need to reference in my webpack built javascript. The images are part of the asset pipeline, living in app/assets/images, because they need to be accessible from the rails views also.

I can think of a few ways to get the paths to JS, but before I started trying things myself, I figured I would check and see if there was an already established way of doing something like this.

Support for multiple chunks

It looks like this gem breaks when using multiple chunks.

The fix seems to be to change Webpack::Rails::Manifest.asset_paths to the following implenentation —

        def asset_paths(source)
          raise WebpackError, manifest["errors"] unless manifest_bundled?

          if manifest["entrypoints"][source] && paths = manifest["entrypoints"][source]['assets']
            # # Can be either a string or an array of strings.
            # # Do not include source maps as they are not javascript
            [paths].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p|
              "/#{::Rails.configuration.webpack.public_path}/#{p}"
            end
          else
            raise EntryPointMissingError, "Can't find entry point '#{source}' in webpack manifest"
          end

        end

Support for preloaded applications (cache manifest early)

We wanted to make sure that the asset manifest is loaded early in our Rails boot process, so that forking servers (like unicorn) have the manifest data cached for new workers, instead of going to disk for it.

I'm using a private api method in an initializer to accomplish this currently:

Webpack::Rails::Manifest.send(:manifest)

Could a public/supported method be added for this?

Weird configuration for dev_server.manifest_host in Rails config

Hi.
Please add information about Rails configuration options available.
It tooks me some time to find a proper way to configure rails with webpack host on 0.0.0.0.
It is not clear without analyzing sources.
And I think it's reasonable to set manifest_host/port default value to something like
proc { config.webpack.dev_server.host ||= 'localhost' }
instead of localhost, because in most cases dev_server.host and manifest_server.host are equal.
Regards.

Multi-compiler mode

This may very well be an issue with webpack and not webpack rails but when using multi compiler mode (https://github.com/webpack/webpack/tree/master/examples/multi-compiler) the manifest that rails reads gets overwritten by each "compile target" so only one package is available in the manifest.

Any way to have both in the manifest? There seems to be a mention of it here: https://www.npmjs.com/package/webpack-manifest-plugin but I have no idea what "pass a shared {} to cache option" really means

Example Docker setup

I wanted to provide my setup with webkit-rails and Docker – if possible, it would be nice to add some of this to the README.

Sample docker-compose.yml file. Note the -b and --host options, which expose the server processes to the host machine.

services:
  webpack:
    env_file: .env
    image: assemble/web
    command: /app/node_modules/.bin/webpack-dev-server --config config/webpack.config.js --host 0.0.0.0
    volumes:
      - .:/app
    ports:
      - 8888:8888

  web:
    build: .
    command: bundle exec rails s -p 3000 -b 0.0.0.0
    ports:
      - "$PORT:3000"
    links:
      - db
      - webpack
    volumes:
      - .:/app

Be sure to set the manifest_host to match the name of the docker-compose webpack service.

# config/application.rb
    config.webpack.dev_server.manifest_host = 'webpack'
    config.webpack.dev_server.manifest_port = 3808
    config.webpack.dev_server.port = 3808

When webpack runs inside a Docker container, it cannot observe the file change events that it needs to re-compile the assets. As a workaround, add to your webpack config:

// config/webkit.config.js
  watchOptions: {
    poll: true
  }

Cannot get hot reload running

Hey,

I've combined your generated webpack config with the one that vue.js generates.
Now I wonder how to get live reload running.

Webpack seems to inject some code that tries to load http://localhost:3808/__webpack_hmr
But that path resolves in Cannot GET /__webpack_hmr.

Is that even needed?

When I include http://localhost:3808/webpack-dev-server.js then the whole page reloads reloads completely. That's not my intent.

Thx in advance!

Best,
Christian

webpack-rails now prevents errors from being shown in console

Hi @mipearson. Thanks for webpack-rails! We've been using it successfully for the last few months, with no complaints until now.

Seems this commit prevents linter and compile errors from getting through to the browser console via webpack-dev-server. Instead I see this annoying Rails error screen:

image

This prevents the project from loading and is a show stopper. Is there a way to turn this off? Also, having this behaviour as default is a breaking change, so I think you should have bumped major version (if you're following semver).

Also I know it's a PITA, but it would be really helpful if you maintained a changelog somewhere. Took us a while to find the issue.

Anybody else hitting this problem: 0.9.7 seems to be the most recent working version.

explicitly define assets server protocol

we just incorporated this into our development process. but we noticed a small snag. we need to serve the assets out of https, while our rails server runs on http. This is because we have a web product (rails server) and a chrome extension product. the chrome extension code must load from an https end point.

since the https setting is already exposed, but it's only used when looking for the inital manifest.json, i thought it would make sense to extend that to the assets themselves as well.

please consider #35

Integration tests todo, suggested approach

WRT to the todo about integration tests that is in the README: I guess the problem with integration tests is the exception that is raised because of the missing manifest?

I put this below in environments/test.rb and it solved the problem with my tests, which were rendering views.

config.webpack.dev_server.host = 'localhost'
config.webpack.dev_server.port = 3000
config.webpack.dev_server.enabled = false
config.webpack.output_dir = "public/webpack"
config.webpack.public_path = "webpack"
config.webpack.manifest_filename = "manifest.json"

Unless this has any drawbacks I don't see yet, it might help to put into the README for others bumping into that question. What do you think?

Helper inserts source maps as well

The Stats plugin does not discriminate between source and sourcemap files and the array based helper will add broken source map links with .js appended to them.

I'm wondering if the MainfestPlugin wouldn't be better for this?

Expose `webpack_asset_paths`

I think it would be beneficial to expose the webpack_assets_path method.

My current use-case:

I'm using a jasmine.yml for configuration in rails. In order to specify the webpack asset files, I'm currently using a copy-pasta of the original (with a slight modification for my CI environment since assets are precompiled).

# Webpack assets
dev_server_enabled = ::Rails.configuration.webpack.dev_server.enabled
port = ::Rails.configuration.webpack.dev_server.port
protocol = ::Rails.configuration.webpack.dev_server.https ? 'https' : 'http'

host = ::Rails.configuration.webpack.dev_server.host
host = instance_eval(&host) if host.respond_to?(:call)

webpack_assets = Webpack::Rails::Manifest.asset_paths('application').map do |file_path|
  if dev_server_enabled
    "#{protocol}://#{host}:#{port}#{file_path}"
  else
    "#{file_path}"
  end
end

...

jasmine_config['src_files'] = [
  *webpack_assets,
]

Note: assuming there is no easy way to access the module's public instance method.

Webpack 2 support?

Hey, just wondering if anyone is working on Webpack 2 support? I know that Rails 5.1 will ship with direct support for this, but my guess is this gem will be highly useful for non 5.1 versions of Rails and Webpack 2 is scheduled for release soon.

If no one is definitely working on this, I might be able to take a look, but if someone has something in progress, I'm also happy to check it out.

Server Side rendering

I like this gem, easy to configure and work, but can you help me with instructions on how to do server side rendering with rails?

Heroku Build fails

Locally rake webpack:compile works like a charm but trying to deploy the app to heroku is a no go, but without much explanation. Looks like the manifest.json file isn't being properly created?

-----> Building dependencies
Installing node modules (package.json)
[email protected] /tmp/build_1c302d7f0ee64607177b83a9037152d4/Design-Inc-DI-app-7136c106d1427415463d0c2b3757798123617599
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ���── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected]

-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Build succeeded!
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

-----> webpack-rails app detected
-----> bundle exec rake webpack:compile
rake aborted!
Hash: 56f5734cd4cb126789c6
Version: webpack 1.13.1
Time: 3988ms
Asset Size Chunks Chunk Names
index-d11041cf5e228483e04a.js 152 kB 0 [emitted] index
manifest.json 0 bytes [emitted]

Webpack::Rails::Manifest::EntryPointMissingError

Hi there,

When I run foreman start, it does not appear to write any files. Is that expected?

When I visit a page, I get ActionView::Template::Error (Can't find entry point 'application' in webpack manifest):

If I run bundle exec rake webpack:compile, the manifest file and a main.js file are correctly compiled but the asset path helper #webpack_asset_paths still doesn't fine them

Thoughts? Did I miss a step in the process?

HTTPS cannot load manifest file

I tried to load webpack with --https and --key and --cert but it doesn't regconize the manifest.json. The connection just halted and return

Webpack::Rails::Manifest::ManifestLoadError
Could not load manifest from webpack-dev-server at http://localhost:3808/webpack/manifest.json - is it running, and is stats-webpack-plugin loaded? (original error Net::ReadTimeout)

I tried running it in http and it worked.

Application Trace | Framework Trace | Full Trace
webpack-rails (0.9.9) lib/webpack/rails/manifest.rb:72:in `rescue in load_dev_server_manifest'
webpack-rails (0.9.9) lib/webpack/rails/manifest.rb:65:in `load_dev_server_manifest'
webpack-rails (0.9.9) lib/webpack/rails/manifest.rb:57:in `load_manifest'
webpack-rails (0.9.9) lib/webpack/rails/manifest.rb:48:in `manifest'
webpack-rails (0.9.9) lib/webpack/rails/manifest.rb:29:in `asset_paths'
webpack-rails (0.9.9) lib/webpack/rails/helper.rb:18:in `webpack_asset_paths'
app/views/layouts/application.html.slim:33:in `_app_views_layouts_application_html_slim___4598633793290155048_70153962050480'
actionview (4.2.1) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.1) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.1) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.1) lib/action_view/template.rb:143:in `render'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.1) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.1) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.1) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.1) lib/action_view/helpers/rendering_helper.rb:32:in `render'
app/views/layouts/dashboard.html.slim:94:in `_app_views_layouts_dashboard_html_slim___2610351862965709552_70153966538300'
actionview (4.2.1) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.1) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.1) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.1) lib/action_view/template.rb:143:in `render'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.1) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.1) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.1) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.1) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.1) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.1) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.1) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.1) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/chrisyeung/.rbenv/versions/2.2.5/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:43:in `render'
meta-tags (2.1.0) lib/meta_tags/controller_helper.rb:26:in `render_with_meta_tags'
wicked_pdf (1.0.6) lib/wicked_pdf/pdf_helper.rb:22:in `render_with_wicked_pdf'
actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.1) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.1) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.1) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.1) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in `call'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.1) lib/action_dispatch/routing/mapper.rb:49:in `serve'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:819:in `call'
omniauth (1.3.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
jquery-fileupload-rails (0.4.6) lib/jquery/fileupload/rails/middleware.rb:14:in `_call'
jquery-fileupload-rails (0.4.6) lib/jquery/fileupload/rails/middleware.rb:10:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
activerecord (4.2.1) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
appsignal (1.2.5) lib/appsignal/rack/rails_instrumentation.rb:28:in `call_with_appsignal_monitoring'
appsignal (1.2.5) lib/appsignal/rack/rails_instrumentation.rb:13:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.1) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
request_store (1.3.1) lib/request_store/middleware.rb:9:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
rack-cors (0.3.1) lib/rack/cors.rb:72:in `call'
railties (4.2.1) lib/rails/engine.rb:518:in `call'
railties (4.2.1) lib/rails/application.rb:164:in `call'
rack-cors (0.3.1) lib/rack/cors.rb:72:in `call'
puma (3.6.0) lib/puma/configuration.rb:225:in `call'
puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
puma (3.6.0) lib/puma/server.rb:415:in `process_client'
puma (3.6.0) lib/puma/server.rb:275:in `block in run'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `call'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'

Could not find generator webpack_rails:install.

Using Rails 3.2.18 and Ruby 2.0 I'm getting the following when running bundle exec rails generate webpack_rails:install (after successful bundle install of webpack-rails):

Could not find generator webpack_rails:install.

Any idea what could cause this?

Is this supposed to repack when I reload my page?

Because it isn't detecting any of my changes. I followed your example with the slight modification of

./node_modules/.bin/webpack-dev-server --config ./config/webpack.config.js --host '0.0.0.0'

because I'm running things through docker compose.

Procfile starting assets webserver on Heroku

Hi people,

How do you people manage the Procfile starting the webpack dev server for development purposes but not starting it on Heroku, which obviously we don't want since the assets were compiled?

I already saw people writing separated Procfiles per ENV (production and development) but I think this solution loses the point of Procfile + ENV vars, so other solutions are welcomed.

Thanks for your attention.

Release as gem

Discussed previously with @lengarvey as to whether this could replace the existing webpack-rails gem on rubygems.

It's ready to be released, now it has proper tests, a README and RDoc.

Loading images with rails helpers

What is the recommended way of referencing images with webpack-rails?

Is it possible to use something like this?

= image_tag *webpack_asset_paths('my-image', extension: 'png')

Image path issue in Heroku production, also have issue with webpack 2

First issue

I have some issues with Image path. I have a React-Rails-Webpack project. I want to add a logo on header. Header,Sidebar and all other items are React components. (React router used for routing )

Webpack config file

      {
        test: /\.(gif|png|jpe?g|svg)$/i,
        loaders:[
          'file?hash=sha512&digest=hex&name=[hash].[ext]',
          'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
        ],
}

Image loaded using require

let LogoImage = require('./icon.png');

Notice: JS and Image files are in same directory

On local server, their is no issue

Local server path <img src="//localhost:3808/webpack/e6a2e7e6cfa80a367c09780b93d2cef6.png" alt="">

But on production (Heroku), the path become

<img src="/e6a2e7e6cfa80a367c09780b93d2cef6.png" alt="">

But file available inside webpack folder in public folder. original path webpack/e6a2e7e6cfa80a367c09780b93d2cef6.png

I have added this on webpack.config file for a quick fix

if (production) {
config.plugins.push(
    new webpack.NoErrorsPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compressor: { warnings: false },
      sourceMap: false
    }),
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify('production') }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin()
  );
  config.output.publicPath = '/webpack/'; // added for quick fix
|

I don;t think this as good solution, Is there any good solution to fix my problem

Second issue

file or directory not found when i use like below

      {
        test: /\.(gif|png|jpe?g|svg)$/i,
       // loaders:[
       //   'file?hash=sha512&digest=hex&name=[hash].[ext]',
        //  'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
       // ],
         loaders:[
          'url-loader','file-loader',
           {
             loader:'image-webpack-loader',
             query: {
               bypassOnDebug:true,
               progressive:true,
              optimizationLevel: 7,
               interlaced: false
             }
           }
         ],
        exclude: /node_modules/,
        include:[
          path.join(__dirname,'..','app','assets','images'),
          path.join(__dirname,'..','app','assets','javascripts','dashboard')
        ],
      }

proposal: TARGET=production is confusing for both rails and node

I know rails and node, so this was a bit of a stumble for me - had to read all the source to get it. I think a simple change would clarify separation of environments.

Context

RAILS_ENV=production - rails developers get it.
NODE_ENV=production - node developers get it.
TARGET=production - wait, what? :)

It seems that TARGET is unnecessarily different than the Rails and Node nomenclature, in that it is set only by the rake task and interpreted in the webpack.js.

Proposal

I propose (and I'll PR if you would like) two changes:

  1. webpack.config.js deals with NODE_ENV only. - node developers get it.
  2. the rake task interprets RAILS_ENV and sets NODE_ENV for compilation. - rails developers get it.

Thoughts?

Suggest handling live-reload in development by default

I had to add <script src="http://localhost:3808/webpack-dev-server.js"></script> to my layout template in order to get livereload working. I'd suggest enabling this by default or via configuration so that it "just works".

Would like to change publicPath

Out of the box the publicPath is public/webpack/, I tried changing it to public/js, which compiles fine into that location but it does not seem to find it there.

ActionView::Template::Error (Could not load compiled manifest from /app/public/webpack/manifest.json - have you runrake webpack:compile? (original error No such file or directory @ rb_sysopen - /app/public/webpack/manifest.json)):

Is there anything I'm missing? Is it possible to change the output location?

404 on application.js, unable to find other manifestts.

I've followed the instructions from the gem markdown.

For some reason I'm getting the rails 404 on /webpack/application.js.

I've tried adding other files alongside application.js but all I'm getting is "Can't find entry point 'main' in webpack manifest". Re-running npm install and restarting Foreman doesn't fix the issue.

Any ideas what I'm doing wrong that would cause this strange behaviour?

Update: I've tried the steps in #58 but no fix.

Update 2: I figured out that I need to add main/main.js to the entry points in webpack.config.js but it's 404ing the same as application.js.

URLs are not supported in production public_path due to leading slash

Hello! Loving webpack-rails, really has been a game changer getting our code migrated away from sprockets.

We deliver our assets from a CDN, so it makes sense for us to define config.webpack.public_path = '//cdn.url.com/assets/webpack'. The problem with this is that manifest.rb always adds a slash before the public path.

Weirdly, the resulting URLs (like "///sub.domain.com/assets/webpack/app.js") work in most browsers, but not all! In IE11 and other old browsers, the public path gets parsed incorrectly, prevent the assets from being loaded.

A workaround is removing one (but not both) of the leading slashes on our CDN url. But this is pretty weird. Is there another way to tell webpack to load assets from another domain?

css assets?

Doesn't seem the gem helper webpack_assets and manifest import css files properly. Any way to add this feature?

package.json information should flex with rails application

This data is static, it seems like it should at least get the name from the rails application.

{
"name": "webpack-rails-example",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"stats-webpack-plugin": "^0.2.1",
"webpack": "^1.9.11",
"webpack-dev-server": "^1.9.0"
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.