Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plugins] Wrong path in compiler.options #149

Closed
pksjce opened this issue Sep 7, 2016 · 3 comments
Closed

[Plugins] Wrong path in compiler.options #149

pksjce opened this issue Sep 7, 2016 · 3 comments
Labels

Comments

@pksjce
Copy link

pksjce commented Sep 7, 2016

From @frantic on October 28, 2015 19:34

x-post from gajus/write-file-webpack-plugin#1:

Seems like for some reason this plugin gets a wrong path in compiler.options. In the following case instead of ./dist I just get /. It seems to just use webpack's API so I suspect it's webpack issue.

My config:

var WriteFilePlugin = require('write-file-webpack-plugin');

module.exports = {
  entry: "./src/main.js",
  output: {
    path: __dirname + "/dist",
    filename: "bundle.js",
    publicPath: "/dist"
  },
  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /(node_modules|examples)/,
      loader: 'babel-loader?stage=0'
    }]
  },
  plugins: [
    new WriteFilePlugin()
  ]
};

but the plugin creates a file in my root - /bundle.js. I've added some logging. The config exported from webpack.config.js looks like this:

{ entry: './src/main.js',
  output:
   { path: '/Users/frantic/code/flexbox/dist',
     filename: 'bundle.js',
     publicPath: '/dist' },
  module: { loaders: [ [Object] ] },
  plugins: [ { apply: [Function: apply] } ] }

however inside plugin's apply when I console.log(compiler.options); I get:

{ entry:
   [ '/usr/local/lib/node_modules/webpack-dev-server/client/index.js?http://localhost:8080',
     './src/main.js' ],
  output:
   { path: '/',
     filename: 'bundle.js',
     publicPath: '/dist',
     libraryTarget: 'var',
     sourceMapFilename: '[file].map[query]',
     hotUpdateChunkFilename: '[id].[hash].hot-update.js',
     hotUpdateMainFilename: '[hash].hot-update.json',
     crossOriginLoading: false,
     hashFunction: 'md5',
     hashDigest: 'hex',
     hashDigestLength: 20,
     sourcePrefix: '\t',
     devtoolLineToLine: false },
  module:
   { loaders: [ [Object] ],
     ...

(note different output.path in both cases)

webpack v1.12.2

cc @gajus

Copied from original issue: webpack/webpack#1563

@pksjce
Copy link
Author

pksjce commented Sep 7, 2016

From @gajus on October 29, 2015 20:48

This appears to be either a bug or undocumented behaviour (gajus/write-file-webpack-plugin#1 (comment)).

Regardless, how do I get the original output.path?

@pksjce
Copy link
Author

pksjce commented Sep 7, 2016

From @sokra on November 14, 2015 21:43

This happens with the webpack-dev-server. It compiles in-memory so there is no need for a output path.

@SpaceK33z
Copy link
Member

With old versions of webpack-dev-server, it forced output.path to /. This has been fixed with webpack/webpack-dev-server#337, so I'm pretty sure this is no longer an issue.

@bebraw bebraw closed this as completed Oct 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants