Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Buffalo needs to be updated to support Webpack 2.2.x #195

Closed
markbates opened this issue Jan 30, 2017 · 7 comments
Closed

Buffalo needs to be updated to support Webpack 2.2.x #195

markbates opened this issue Jan 30, 2017 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@markbates
Copy link
Member

No description provided.

@markbates
Copy link
Member Author

/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/webpack/lib/Chunk.js:59
		throw new Error("Chunk.entry was removed. Use hasRuntime()");
		^

Error: Chunk.entry was removed. Use hasRuntime()
    at Chunk.get entry [as entry] (/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/webpack/lib/Chunk.js:59:9)
    at /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/extract-text-webpack-plugin/index.js:201:13
    at Array.filter (native)
    at Compilation.<anonymous> (/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/extract-text-webpack-plugin/index.js:200:37)
    at Compilation.applyPlugins0 (/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/tapable/lib/Tapable.js:68:14)
    at Compilation.seal (/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/webpack/lib/Compilation.js:558:8)
    at /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/webpack/lib/Compiler.js:474:16
    at /Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/tapable/lib/Tapable.js:225:11
    at _addModuleChain (/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/webpack/lib/Compilation.js:472:11)
    at processModuleDependencies.err (/Users/markbates/Dropbox/development/gocode/src/github.com/markbates/coke/node_modules/webpack/lib/Compilation.js:443:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

@stanislas-m
Copy link
Member

webpack/webpack#2764

[...] as others in this thread have pointed out, you need to install a webpack2.0-compatible version of the plugin.
npm install extract-text-webpack-plugin@^2.0.0-beta --save-dev

@markbates
Copy link
Member Author

@stanislas-m the generated webpack.config.js needs to also be updated to use the new extract-text-webpack-plugin as they changed the API, so some work needs to happen in addition to just using a newer plugin version.

@stanislas-m stanislas-m self-assigned this Feb 3, 2017
@stanislas-m
Copy link
Member

This webpack.config.js works with the extract-text-webpack-plugin v2.0.0-beta, but they will change the API again before the release (webpack-contrib/postcss-loader#92 (comment)). I think we have to wait for this release.

var webpack = require("webpack");
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
  entry: [
    "./assets/js/application.js",
    "./assets/css/application.scss",
    "./node_modules/jquery-ujs/src/rails.js"
  ],
  output: {
    filename: "application.js",
    path: "./public/assets"
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    }),
    new ExtractTextPlugin("application.css"),
    new CopyWebpackPlugin([{
      from: "./assets",
      to: ""
    }], {
      ignore: [
        "css/*",
        "js/*",
      ]
    })
  ],
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loader: "babel-loader",
      exclude: /node_modules/
    }, {
      test: /\.scss$/,
      loader: ExtractTextPlugin.extract({
        fallbackLoader: "style-loader",
        loader: [{
          loader: "css-loader",
          options: { sourceMap: true, importLoaders: 1 }
        },
        {
          loader: "sass-loader",
          options: { sourceMap: true }
        }]
      })
    }, {
      test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=application/font-woff"
    }, {
      test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=application/font-woff"
    }, {
      test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=application/octet-stream"
    }, {
      test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
      loader: "file-loader"
    }, {
      test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=image/svg+xml"
    }]
  }
};

@markbates
Copy link
Member Author

If they're going to change it again before release we should wait. Thanks for digging into this.

@markbates markbates modified the milestones: 0.7.3, 1.0.0 Feb 6, 2017
@jbarone
Copy link

jbarone commented Feb 7, 2017

I got it working with webpack v2.0.0 using the following config

var webpack = require("webpack");
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
  entry: [
    "./assets/js/application.js",
    "./assets/css/application.scss",
    "./node_modules/jquery-ujs/src/rails.js"
  ],
  output: {
    filename: "application.js",
    path: "./public/assets"
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    }),
    new ExtractTextPlugin("application.css"),
    new CopyWebpackPlugin([{
      from: "./assets",
      to: ""
    }], {
      ignore: [
        "css/*",
        "js/*",
      ]
    })
  ],
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loader: "babel-loader",
      exclude: /node_modules/,
      query: {
        presets: ['es2015', 'react']
      }
    }, {
      test: /\.scss$/,
      loader: ExtractTextPlugin.extract({
        fallback: "isomorphic-style-loader",
        use: [{
          loader: 'to-string-loader'
        },{
          loader: "css-loader",
          options: { sourceMap: true, importLoaders: 1 }
        },
        {
          loader: "sass-loader",
          options: { sourceMap: true }
        }]
      })
    }, {
      test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=application/font-woff"
    }, {
      test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=application/font-woff"
    }, {
      test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=application/octet-stream"
    }, {
      test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
      loader: "file-loader"
    }, {
      test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
      loader: "url-loader?limit=10000&mimetype=image/svg+xml"
    }]
  }
};

the root cause seems to be style-loader which is designed only for use on the client, and not server side rendering. In this case the DOM isn't present and the code fails looking for window.

I wound up modifying the example above, because it was still failing for me, to include the to-string-loader which seemed to fix everything for me. I also used isomorphic-style-loader as a fallback, since it is a drop in replacement for style-loader which will handle the server side rendering.

@fooflare
Copy link
Contributor

extract-text-webpack-plugin-2.0.0 has been released as stable, buffalo is broken with current webpack.config.js #262. This issue should be solved or specify its version to a compatible one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants