Code Monkey home page Code Monkey logo

hjs-webpack's Introduction

hjs-webpack

npm version

Warning: If you are upgrading across major versions, please read the release notes in the changelog.

I really dislike setting up build scripts. Most of the time I want to do the exact same thing:

While developing:

  • easy to setup and run dev server
  • transpile ES6+, JSX, Stylus code
  • hotload (a.k.a. live reload) modules when changed

When ready to ship:

  • minify and bundle all the things
  • output minified, uniquely named static files into public directory
  • be able to generate customized static HTML file(s) used to deliver my JS app
  • be ready to just upload it all to something like surge.sh
  • sometimes I want to pre-render all known HTML into static HTML files and have React take over once the clientside JS loads.

webpack can do most of those things pretty well out of the box. But, it sure is a pain to set it all up.

So, this is just a simplified, opinionated way to configure webpack for development and then build for production. That also supports easily generating more files.

If no one uses it but me, it will have still served its purpose.

A screencast showing how to use this module is here: http://learn.humanjavascript.com/react-ampersand/setting-up-webpack

install

npm install hjs-webpack

Optional dependencies

hjs-webpack relies on a number of optional dependencies to add functionality for things like CSS preprocessing, ES2015 transpiling, templates, and plugins. It doesn't make sense to specifiy all the loaders as peerDependencies since not every person will want every loader and missing peerDependencies cause commands like npm ls to error which isn't great.

So in order to get this additional functionality you should npm install the loaders and plugins you want hjs-webpack to use. If hjs-webpack detects that they are installed, then they will be used automatically without any further configuration.

Here's some more information about the available loaders and plugins and what they each do. You should install each that you want with npm install --save-dev.

CSS

Note that all of the CSS loaders and plugins require css-loader postcss-loader style-loader to be installed.

less-loader Require compiled less files. Extension: less.

stylus-loader Require compiled stylus files. Extension: styl.

sass-loader Require compiled sass files using the regular or indented syntax. Extensions: sass scss.

yeticss A plugin to add the yeticss library as a stylus plugin.

autoprefixer A plugin to auto prefix all your CSS with the necessary vendor prefixes.

JS/JSX/JSON

babel-loader Require transpiled JS with built-in support for ES2015 and JSX. Extensions: js jsx babel.

coffee-loader Require CoffeeScript. Extension: coffee.

cjsx-loader Require CoffeeScript with support for JSX. coffee-loader must also be installed. Extension: cjsx.

awesome-typescript-loader Require TypeScript. Extension: ts.

livescript-loader Require LiveScript. Extension: ls.

Assets

url-loader Require assets that return data url if the size is less than the urlLoaderLimit. Extensions: jpg jpeg png gif svg otf eot svg ttf woff.

worker-loader This lets us more easily write code for WebWorkers. Once you npm install worker-loader you can write worker code using whatever other transpiler you're using and being able to require or import code from npm just like you would normally. If this is installed, simply name your file ending in worker.js for example main.worker.js or even just worker.js and it will be loaded as a worker and packaged up as a separate file when built. In addition, worker-loader supports inlining the code for workers and loading it as a data-uri as can be seen here: https://github.com/webpack/worker-loader/blob/master/createInlineWorker.js. To use this feature name your file SOMETHING.thread.js or just thread.js instead and it will be inlined if that feature is supported by the browser running your app (it will fallback to being loaded as a separate file otherwise).

Templates

pug-loader Require pug files as compiled functions. Extension: pug (legacy jade also supported).

Development

visualizer-plugin A plugin to visualize and analyze your Webpack bundle to see which modules are taking up space and which might be duplicates.

Usage

Step 1. install it into your project

npm install --save hjs-webpack

Step 2. create a webpack.config.js

Put it at the root of your project, a typical config looks something like this:

var getConfig = require('hjs-webpack')


module.exports = getConfig({
  // entry point for the app
  in: 'src/app.js',

  // Name or full path of output directory
  // commonly named `www` or `public`. This
  // is where your fully static site should
  // end up for simple deployment.
  out: 'public',

  // This will destroy and re-create your
  // `out` folder before building so you always
  // get a fresh folder. Usually you want this
  // but since it's destructive we make it
  // false by default
  clearBeforeBuild: true
})

Step 3. configure scripts section of package.json

I usually add something like the following scripts:

"scripts": {
  "start": "hjs-dev-server",
  "build": "webpack",
  "deploy": "npm run build && surge -p public -d somedomain.com"
}

Assuming you've got some JS written that you've set as your in in the webpack.config.js you can run npm start and open a browser to http://localhost:3000 and you everything should Just Work™.

When you're wanting to do a build, just run npm run build. The build will generate your files into public.

Now there's a static site in public that can be deployed to something like Surge.sh, which I do by running npm run deploy.

Step 4. Dealing with styles

Since we're using webpack under the hood, this is done the "webpack way".

Basically you can require your styles as if they were JavaScript files.

Simply do this in your application code:

require('./path/to/your/css/main.css')

Be sure to include the extension: .css in your require statement. If you use .styl you can write Stylus seamlessly and at the top of your stylus files you've got access to yeti.css for easy styling.

Try creating a file called main.styl containing:

@import 'yeticss'

Require it from your main application file (see in section below) and you should get some nice default styles.

Note in development mode these will be live-reloaded (hot loaded). In production, these will be extracted into their own files, including intelligent handling of referenced URLs within your stylesheets. Things like font-files and images will be extracted if they're over a certain size. You shouldn't have to worry about this too much. It should just work seamlessly.

Step 5. Dealing with images and static files

Option #1: requiring files

Webpack lets us do var url = require('something.png') from within our app code and url is something you can safely set as the src of an image tag, for example. When you build the project, it uses the url-loader and will base64 encode and inline it if it's smaller than the urlLoaderLimit and hash and export it otherwise.

When you do this, webpack will hash the file and use that as a name. If you basically just want to require a file so webpack knows about it, the following syntax will copy the favicon to the out directory (at the root) but leave the name unchanged: require('!!file?name=favicon.ico!./real/path/to/your/favicon.ico'). The !! at the beginning will tell webpack to ignore other configured loaders so that your favicon won't get base64 encoded by the url-loader. See the webpack documentation about loader order for more info.

But, letting webpack handle images isn't always what you want to do. Sometimes you want just a simple folder of static assets and be able to reference them like you're used to. That's why there's another option:

Option #2: just put 'em in your out directory

You can also just put your assests in the out directory and tell hjs-webpack to ignore them by setting a glob pattern as the clearBeforeBuild option.

Assume an out directory called public that looks like this:

public/
  some-other-generated-file.html
  index.html
  yourapp.1.1.1.css
  yourapp.1.1.1.js
  favicon.ico

  images/
    some-pic.png

Then, instead of setting clearBeforeBuild: true you can set it to a glob string like so: clearBeforeBuild: '!(images|favicon.ico)'.

Now when you build it'll clear everything that matches the glob pattern an nothing else.

In this case, it'd leave the images directory and your favicon.ico alone (more details in options section below).

note The development server will treat the out directory as the contentBase which means in this case the favicon would be available at /favicon.ico despite being in public.

Examples

There are 3 example projects in the /examples directory with various config setups:

  1. Only generating CSS/JS
  2. Generating CSS/JS and using included HTML template
  3. Pre-rendering app layout and the public homepage HTML with React as part of the build process

Config options

The main export you get when you require('hjs-webpack') is simply a pre-configured webpack.config.js. You could take the result of that and add other plugins if you so chose, but shouldn't be necessary for most common tasks.

in

This should just be the path to the file that serves as the main entry point of your application.

out

Path to directory where we're going to put generated files.

clearBeforeBuild (optional, boolean or glob string, default=false)

A boolean to specify whether to clear the out folder before building.

If you wish to only clear some of this directory you can also pass a glob string. Globs are the file path matching strings you've probably seen in on the command line or in a .gitigore (i.e. **/*.js*).

The most common thing you'd probably want to do while using this module would be to exclude a directory from being cleared. The following example would clear out the public directory but leave the public/images and public/static folders intact if they exist.

getConfig({
  in: 'src/app.js',
  out: 'public',
  clearBeforeBuild: '!(images|static)'
})

So, just to be clear, everything that matches the glob string within the out folder will be deleted when building.

isDev (optional, boolean, default=varies based on command)

A boolean to indicate whether or not everything is in production mode (minified, etc.) or development mode (everything hotloaded and unminified).

By default this value is true if the command you ran contains hjs-dev-server and false otherwise. The option exists here in case you need to override the default.

devtool (optional, string, default='cheap-module-eval-source-map')

A webpack developer tool to enhance debugging. See the webpack docs for more options.

uglify (optional, object)

Options passed directly to the UglifyJSPlugin. Only used if isDev is false. Default:

{
  compress: { warnings: false },
  output: { comments: false },
  sourceMap: false
}

output.filename (optional, string)

This is passed directly to webpack, so you can use all the configuration options available there.

By default a filename is created for you based on the following rules:

  • If isDev is true, then the filename is app.js
  • If isDev is false, then the filename NAME.VERSION.js where NAME and VERSION are pulled from your package.json file
  • If output.hash is true, then instead of VERSION your filename will contain the HASH of the compiled file

output.cssFilename (optional, string)

This is passed directly to the extract-text-webpack-plugin, so you can use all the configuration options available there. Note: this is only used if isDev is true, since in development mode the css bundle is inserted dynamically into the document by the style-loader.

By default a filename is created for you based on the following rules:

  • If isDev is true, then the filename is app.css
  • If isDev is false, then the filename NAME.VERSION.css where NAME and VERSION are pulled from your package.json file
  • If output.hash is true, then instead of VERSION your filename will contain the HASH of the compiled file

output.hash (optional, boolean, default is false)

This is used in conjunction with the output.filename and output.cssFilename options above, and is only used if isDev is false. If hash is true then the filenames of your JS and CSS files will contain the hash of the compiled file. This is useful to fingerprint your asset files so that they can be cached for as long as possible.

urlLoaderLimit (optional, number, default: 10000)

This is the default threshold to use for whether URLs referenced in stylesheets will be inlined or extracted during build (we're just pre-configuring the url-loader).

devServer (optional, object)

These options are passed through to the hjs-dev-server with a few defaults. Some of these options are passed directly to webpack-dev-middleware, see those docs for all available options.

{
  port, // pulled from top level option "port"
  hostname, // // pulled from top level option "hostname"
  historyApiFallback: true,
  hot: true,
  compress: true, // enable express compression to faster index reload (default: false)
  // The following options are for webpack-dev-middleware
  noInfo: true,
  quiet: false,
  lazy: false,
  publicPath // pulled from top level option "output.publicPath"
}

https (optional, boolean, default: false)

This is used to start hjs-dev-server with its self signed certificate, so you can load the application with an https url. It also configures hot module replacement to also use https.

replace (optional, object)

You can supply an object of require names with paths to the files you want that name to represent. This makes it easy to do things like swapping out config files based on build mode, etc.

Adding this to your config would mean that any time you did: require('config') within your application code, you'd end up with the file specified by the path.

{
  'config': '/some/path/config.json'
}

html (optional, can be boolean or function)

This option is true by default. This means, by default, we'll serve and generate a very basic HTML file that looks like this:

<!doctype html>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<link rel="stylesheet" href="/package-name.1.0.0.css"/>
<body><div id="root"></div><script src="/package-name.1.0.0.js"></script></body>

Note the <meta charset> tag and mobile viewport settings are there by default.

The <body> followed by the main script tag is also intentional. The ordering ensures we don't have to wait for DOMReady in our clientside code, you can safely assume that both document.body and document.head will be available when your script executes.

If you just want to do JS and CSS and handle all the html yourself, simply add html: false to your config (see examples directory for example).

using an html function to generate specific files

This is where it gets interesting. Imagine pre-rendering all known structural content for a Native Web App to static files. Users get pixels on the screen immediately, your JS takes over when downloaded. If you're using React, this "taking over" can be completely seamless and invisible to the user. It's also possible with this approach to write an app that works entirely without JS. See the prerendered-html-files example.

Your function should produce an object.

Each key in the object is a filename, and its value is a string to be written to disc.

If you simply specify html: true it will do the following by default:

html: function (context) {
  return {
    'index.html': context.defaultTemplate()
  }
}

So if you want to produce other files, you can do so by adding them to the returned object:

html: function (context) {
  return {
    'index.html': context.defaultTemplate(),

    // if you build it entirely yourself it should be a complete HTML document
    // using whatever templating system you want
    'other.html': '<!DOCTYPE><body><h1>Hello World</h1></body>'
  }
}

async version

html: function (context, callback) {
  // do whatever async stuff generate result object
  // and pass it to the callback instead
  db.fetchData(function (err, data) {
    callback(null, {
      'index.html': buildHTML(data),
      'other.html': doSomethingElse(data)
    })
  })
}

The context argument

Your html function will be called with a context object that contains the following:

  1. context.main: the name of the generated JS file
  2. context.css: the name of the generated CSS file. This only exists if isDev is false, since in development mode the css bundle is inserted dynamically into the document by the style-loader.
  3. context.defaultTemplate() a convenience method you can call to generate the basic HTML shown above. This takes a few options too if you just want to make minor tweaks. If you want to do more, just don't use the default template, generate your own instead. The options are:
  • {html: '<div id="my-container">Some custom markup</div>'} This markup will be added inside the <body> tag. By default it adds a <div id="root"></div> as a mount target for React apps.
  • {charset: 'utf-8'} what charset to set
  • {title: 'your app'} sets <title>
  • {head: 'any string'} anything else you want to put in the head, other meta tags, or whatnot.
  • {metaViewport: boolean|object} set to false if you don't want the default viewport tag. Set to an object with userScalable true if you don't want to block user-zoom on mobile
  • {publicPath: 'http://mycdn.com/'} (default /) pass in path that will prefix the generated css/js files in the template. Note, there is output.publicPath provided by webpack, but doesn't easily allow for switching based on envirnoment. In this method we've got access to context.isDev and can easily switch based on that.
  • {metaTags: {}} lets you easily add <meta> tags to the document head. Takes an object where the key is the name and the value is the content.
  • {lang: 'en-US'} sets the lang attribute on the <html> tag.
  1. context.isDev: boolean specifying whether or not we're in dev mode.
  2. context.package: the parsed package.json file as an object.
  3. context.stats: the stats object returned by webpack. Of likely interest is context.stats.hash (a hash of current build). context.stats.assets is an array of all the assets that will be generated. This can be useful for generating cache manifests, etc. Overall, this is a big object that lists all the modules in your whole app. You likely won't need most of it, but it's all there in case you do. (A sample can be found here).

serveCustomHtmlInDev (optional, boolean, default is true)

By default, if you supply an html function it will always be used, whether you're in development mode or not.

Set this option to false to only use your html function when building for production. Note, that .isDev is attached to the context object passed to the html function as described above, so alternately you could just use that value to branch your logic within that function. Using this option circumvents the custom html function entirely during development.

Proxy

The dev server uses http-proxy-middleware to optionally proxy requests to a separate, possibly external, backend server. Proxies can be specified with devServer.proxy. This can be a single proxy, or an array of proxies. The proxy context and options are passed directly to http-proxy-middleware.

getConfig({
  in: 'src/app.js',
  out: 'public',
  clearBeforeBuild: true,

  // Use devServer.proxy to specify proxies
  devServer: {
    proxy: {
      context: "/api",
      options: {
        target: "http://localhost:3001",
        pathRewrite: {
          "^/api": ""
        }
      }
    }
  }
})

Developing on multiple devices at once

If you're building an app that you want to look good on all devices it's nice to be able to run them all at once.

Hotloading makes this extremely nice and convenient.

If you're on a Mac, this is fairly simple. Just add a hostname option to your config like so:

module.exports = getConfig({
  in: 'src/app.js',
  out: 'public',

  // set this to whatever your machine name is
  // plus `.local`
  // my machine is `loki` so I do:
  hostname: 'loki.local'
})

Now when you run the development instead of going to localhost open: http://{{yourmachine}}.local:3000 on any device that's on your local network, they should all connect and all hotload your style and JS changes.

Extending hjs-webpack

hjs-webpack is not designed to take all the same options as webpack. Instead it is designed to take the config options listed above and return an object that is then consumed by webpack. That means that if you want to change/add/remove anything in the config, it is the same as manipulating any JavaScript object.

Here's an example where hjs-webpack is used to create the base webpack config, and then it is manipulated to add a new loader, plugin, and option.

var webpack = require('webpack')
var getConfig = require('hjs-webpack')
var config = getConfig(myHjsWebpackOptions)

// Add xml-loader
config.module.rules.push({ test: /\.xml$/, use: ['xml-loader'] })

// Add webpack PrefetchPlugin
config.plugins.push(new webpack.PrefetchPlugin([context], request))

// Add a separate entry point for jQuery
config.resolve.alias = { jquery:'jquery/src/jquery.js' }
config.plugins.push(
  new webpack.ProvidePlugin({
    jQuery: 'jquery',
    $: 'jquery',
    'window.jQuery':'jquery'
  }),
  new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js')
);
config.entry = {
  // Add entries for vendors
  vendors: ['jquery'],
  // Reassign previous single entry to main entry
  main: config.entry
};

// Export the newly manipulated config
module.exports = config

Changing Babel config

Since hjs-webpack already has a babel loader, the easiest way to tweak Babel settings is to create a file at the root of your project called .babelrc that contains config settings. See babelrc docs for more options.

There are some babel presets that work well with hjs-webpack. You can check out an example of using presets in the examples directory. There's one with hot reloading and one without. You'll need to install these presets just like any other dev dependencies.

Here's a quick example if you like copy/pasting:

npm install babel-preset-es2015 babel-preset-react babel-preset-react-hmre --save-dev

and then your .babelrc

{
  "presets": ["es2015", "react"],
  "env": {
    "development": {
      "presets": ["react-hmre"]
    }
  }
}

Credits

This is mostly just some add-ons to webpack so most of the credit goes there.

If you're interested in building apps this way, watch the free section of the tutorials at http://learn.humanjavascript.com. It shows basic usage of this module. Also, you can follow me on twitter @HenrikJoreteg.

Big thanks to co-maintainer @LukeKarrys for helping find/fix some really annoying bugs.

Contributing/Forking

Beware that this is all highly opinionated and contains a lot of personal preferences. If you want to add or remove major things, feel free to open issues or send PRs, but you may just want to fork it.

Changelog

See the CHANGELOG.md

license

MIT

hjs-webpack's People

Contributors

alejandronanez avatar anderser avatar ariddell avatar chabou avatar chrisvfritz avatar clintonhalpin avatar coryhouse avatar dignifiedquire avatar eins78 avatar fampinheiro avatar flokli avatar fweinb avatar greenkeeperio-bot avatar hacdias avatar hatlen avatar henrikjoreteg avatar imranismail avatar ivarni avatar jason-cooke avatar latentflip avatar lukekarrys avatar markwoon avatar queicherius avatar rvanmil avatar sansthesis avatar selbekk avatar spadavecchia avatar tdd avatar thr1ve avatar wkillerud 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  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

hjs-webpack's Issues

define plugin overriding proccess.env causes issues with node webkit production build

I had an issue where I could no longer access the environment variables in process after I built a production version of an app for node webkit. I solved the issue by removing the define plugin:

 new webpack.DefinePlugin({
        'process.env': {NODE_ENV: JSON.stringify('production')}
      })

This seems to overwrite the process.env variable completely (for node webkit) which I assume isn't the intended behaviour. I'm not sure if there's a way around it other than to removed the plugin.

The webpack DedupePlugin seems to break `npm run build` for the prerendered html example

More specifically, setting NODE_ENV=production before running webpack seems to cause this error.

Error: No template for dependency: TemplateArgumentDependency
    at doDep (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/NormalModule.js:116:23)
    at Array.forEach (native)
    at doBlock (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/NormalModule.js:125:22)
    at DependenciesBlock.NormalModule.source (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/NormalModule.js:159:2)
    at Tapable.ModuleTemplate.render (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/ModuleTemplate.js:14:28)
    at Tapable.Template.renderChunkModules (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/Template.js:80:31)
    at Tapable.<anonymous> (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/MainTemplate.js:28:22)
    at Tapable.applyPlugins [as applyPluginsWaterfall] (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/node_modules/tapable/lib/Tapable.js:37:47)
    at Tapable.MainTemplate.render (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/MainTemplate.js:111:20)
    at Tapable.createChunkAssets (/Users/johnloy/Code/hjs-webpack/examples/prerendered-html-files/node_modules/webpack/lib/Compilation.js:807:32)

Setting NODE_ENV to anything other than production seems to work fine.

Commenting this line seems to supress the problem, though I haven't dug into why:
https://github.com/HenrikJoreteg/hjs-webpack/blob/master/index.js#L116

html plugin does not respect publicPath setting

I'm trying to set the publicPath to '' as I need to generate relative paths for my output. But neither

var config = createConfig({
  // ...
  publicPath: ''
})

nor

var config = createConfig({
  // ...
  output: {
    publicPath: ''
  }
})

are passed to the html plugin, so that I end up with paths /app.js and /app.css in my output, even though I need app.js and app.css

html function does not return full context object as stated in documentation

In the html function of the config file, the context argument does not return the CSS filename as stated. There is no mention in the documentation of any trigger/option that would make this attribute show up or not.

var getConfig = require('hjs-webpack')
var isDev = process.env.NODE_ENV !== 'production'

module.exports = getConfig({
  in: 'src/app.js',
  out: 'build',
  clearBeforeBuild: true,
  isDev: isDev,
  html: function (context) {
    console.log(context); // <-------- no context.css attribute is generated
    return {
      'index.html': '<!DOCTYPE><body><h1>Hello World</h1></body>'
    }
  }
})

Using the LESS styles option. Imported the correct LESS loader. Works when running in dev and the LESS file is required on a view. But will not work when running build command (undefined context.css attribute).

PNG support for urls in CSS modules

First off, I am loving this app setup from the human javascript videos. Great job on those (and this), @HenrikJoreteg

In my project, I needed to add the following loader in order to get my app to compile with some PNGs that were referenced in some CSS files { test: /\.png/, loader: 'url?limit=100000&mimetype=image/png' }

This seems like a common use case, should the PNG loader be added by default? Or should we have the option to add additional loaders in the webpack.config options?

Where to put entry.vendors

I went to your FluentConf where you had us use this module. I'm struggling with this module (and all of webpack for that matter), I have vendor JS + CSS files that I want to put in entry.vendors

My config file:

module.exports = getConfig({
    //entry point
    in: 'src/app.jsx',
    out: 'public', //where compiled files will end up when finished
    isDev: process.env.NODE_ENV !== 'production',
    html: function(data){
        return { 'index.html': data.defaultTemplate() }; //default template
    },
    clearBeforeBuild: true,
    port:8080,
    entry:{
        vendors:[
            'jquery'
        ]
    },
    resolve:{
        alias:{
            jquery:'jquery/src/jquery.js'
        }
    },
    resolveLoader:{
        root: path.join( __dirname, 'node_modules')
    },
    plugins:[
        new webpack.ProvidePlugin({
            jQuery: 'jquery',
            $: 'jquery',
            'window.jQuery':'jquery'
        }),
        new webpack.optimize.CommonsChunkPlugin('vendors','vendors.js')
    ]
});

this error:

node_modules\webpack\lib\NormalModuleFactory.js:70
                        var elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!")
                                               ^
TypeError: undefined is not a function
    at Tapable.<anonymous> (C:\nodeProj\facebook\clientSide\node_modules\webpack\lib\NormalModuleFactory.js:70:27)
    at Tapable.<anonymous> (C:\nodeProj\facebook\clientSide\node_modules\webpack\lib\NormalModuleFactory.js:27:4)
    at Tapable.<anonymous> (C:\nodeProj\facebook\clientSide\node_modules\webpack\lib\NormalModuleFactory.js:154:3)
    at Tapable.applyPluginsAsyncWaterfall (C:\nodeProj\facebook\clientSide\node_modules\webpack\node_modules\tapable\lib\Tapable.js:75:69)
    at Tapable.NormalModuleFactory.create (C:\nodeProj\facebook\clientSide\node_modules\webpack\lib\NormalModuleFactory.js:139:7)
    at Tapable.<anonymous> (C:\nodeProj\facebook\clientSide\node_modules\webpack\lib\Compilation.js:211:11)
    at C:\nodeProj\facebook\clientSide\node_modules\webpack\node_modules\async\lib\async.js:182:20
    at C:\nodeProj\facebook\clientSide\node_modules\webpack\node_modules\async\lib\async.js:234:13
    at _arrayEach (C:\nodeProj\facebook\clientSide\node_modules\webpack\node_modules\async\lib\async.js:85:13)
    at _each (C:\nodeProj\facebook\clientSide\node_modules\webpack\node_modules\async\lib\async.js:76:13)

If I remove this snippet, it bundles, but does not accomplish what I'm trying to do.

entry:{
    vendors:['jquery']
}

source maps should be enabled

hey there!

By default hjs-webpack doesn't seem to enable source maps. Is there a good reason for that?
I figured out that I have to run webpack-dev-server -d to enable them, but maybe that should be documented somewhere?

It was confusing for me, because the line numbers in the dev tools console didn't make any sense and I figured a sophisticated setup like this would surely enable source maps by default.

Favicon support?

I was creating a new app using this and realized my favicon was all gross. I was slightly confused at first how to do so, but figured it out. Would there be any interest in a PR to have an example to place one on the generated app?

Or alternatively, would there be interest in augmenting the html plugin to support a favicon url?

Changing Babel configuration

Leaving this here in case it helps others. Maybe this can fit in the README somewhere?

Here's an example webpack.config.js enabling "stage 0" feature support:

var getConfig = require('hjs-webpack')

var config = getConfig({
  in: 'src/app.js',
  out: 'public',
  clearBeforeBuild: true
})

config.module.loaders[0].loaders[1] = 'babel-loader?stage=0'
module.exports = config

You might notice a hard assumption about where the babel-loader is defined within the module loaders list. If you prefer you can replace

config.module.loaders[0].loaders[1] = 'babel-loader?stage=0'

with something like this to be a little more future-proof:

config.module.loaders.forEach(function (filter) {
  if (filter.loaders) {
    filter.loaders.forEach(function(loader, idx, arr) {
      if (loader === 'babel-loader') {
        arr[idx] = 'babel-loader?stage=0'
      }
    })
  }
})

Update examples to babel 6

Warning: Noob question here!

I'm not sure if this is correct but probably I should wait until hjs-webpack is configured for babel 6.

Is this true?

(sorry for spamming your issues)

Option to name files with hash instead of version

I think this is possible currently by passing in the ha and CSS filenames but the Js and CSS names using different identifiers to specify the hash. It'd be nice to have an option to make this easy

CSS Modules css-loader issue

Hi there guys, I don't want to spam here but I think this is the right place for my question.

By having this:

/*test.css*/

.foo {
    color: red;
};

.bar {
    color: blue;
};

And importing it using import styles from './test.css'

// webpack.config.js

config.module.loaders.push({
    test: /\.css$/,
      loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
});

I got this error on npm start -> (webpack-dev-server)

ERROR in ./~/css-loader!./~/postcss-loader!./~/style-loader!./~/css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./src/containers/test.css
/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/style-loader/index.js!/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/index.js?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!/Users/alejandro/Code/projects/redux-nav-exercise/src/containers/test.css:1:4: Unknown word
// style-loader: Adds some css to the DOM by adding a <style> tag
   ^


ERROR in ./~/css-loader!./~/postcss-loader!./~/style-loader!./~/css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./src/containers/test.css
Module build failed: TypeError: Cannot read property 'toString' of undefined
    at new Input (/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/node_modules/postcss/lib/input.js:31:23)
    at parse (/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/node_modules/postcss/lib/parse.js:21:17)
    at new LazyResult (/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:57:24)
    at Processor.process (/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/node_modules/postcss/lib/processor.js:36:16)
    at processCss (/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/lib/processCss.js:171:11)
    at Object.module.exports (/Users/alejandro/Code/projects/redux-nav-exercise/node_modules/css-loader/lib/loader.js:24:2)
 @ ./src/containers/test.css 4:14-280 14:20-286

Am I missing something here? Am I editing wrong my loaders section of the webpack.config.js If this question is totally missplaced, please let me know and I close it.

Add Nib

Hey! neat Scaffold. I would say people use nib a lot more than yeticss, so why not throw it in? Just need to add it as a peerdep and require it in the base-config.js file

Separate HTML building into seperate webpack plugin

Hi Henrik,

Was in your frontend masters workshop today (tonight for me). I told in the chat that I would love to use this in my (already fleshed out) webpack config. The moderator suggested that I'd do it myself and do a PR. I'd love to give it a try. Would you be interested. Maybe you can give me a few pointers to get started?

Cheers,

JH

Give this a better name

"hjs-webpack" is boring and dull.

a few of my silly ideas (these things that are available on npm)

easier
shades
carefree
helpy
helperton
boat
simpleton
robut
minion

what do you think @lukekarrys?

Uglify with mangle

Noticed by default npm run build will concat+minify but not mangle. Is mangle not a best practice? .. wondering if we should have that as an option? With source maps of course.

Live reload issue

Hi there, I'm having issues with live loading. Every time I save something I have to reload my browser manually in order to see the changes.

Here are some files and a video showing the issue.

By having this on my project:

// webpack.config.js

var getConfig = require('hjs-webpack');

module.exports = getConfig({
    in : 'client/src/app.js',
    out: 'client/public',
    clearBeforeBuild: false
});
// ./client/src/app.js

var test = 1000;
console.log('==============');
console.info('Test: ', test);
console.log('==============');
// package.json
"scripts": {
  "start": "webpack-dev-server"
},
"devDependencies": {
  "babel-core": "6.2.1",
  "babel-loader": "6.2.0",
  "babel-preset-es2015": "6.1.18",
  "babel-preset-react": "6.1.18",
  "hjs-webpack": "5.0.1",
  "webpack": "1.12.8",
  "webpack-dev-server": "1.12.1"
}

I run npm start, open my browser on http://localhost:3000 and this is what I get

cyki3m3scj

[HMR] The following modules couldn't be hot updated: (They would need a full reload!) log-apply-result.js?d762:13
[HMR] - 61 log-apply-result.js?d762:13

Thank you very much!

Routing to 200.html like surge.sh

Unless I've got the wrong end of the stick, it seems that the development server routes all unknown routes that have no file extension to index.html, whereas surge.sh routes all unknown all routes, regardless of file extension, to 200.html.

Is there a way to configure the dev server to be consistent with surge.sh?

Allow contentBase for devServer config

Hi,

I'm currently trying to serve the file from my asset directory, but setting contentBase in the config doesn't seem to work and I suspect that it's being overwritten in here everytime:

    config.devServer = {
      port: spec.port,
      info: false,
      historyApiFallback: true,
      host: spec.hostname,
      // For some reason simply setting this doesn't seem to be enough
      // which is why we also do the manual entry above and the
      // manual adding of the hot module replacment plugin below
      hot: true
    }

I'm doing it using webpack-dev-server --content-base public right now, but would love to be able to pass this in in webpack.config.js file using

module.exports = getConfig({
  in: './client.jsx',
  out: 'public',
  output: {
    filename: "build/main.js",
  },
  devServer: {
    contentBase: './public'
  },
  hostname: '0.0.0.0',
  port: 3000
}

Error in webpack building

Hi @HenrikJoreteg, thank you for this awesome plugin. I found this via your human javascript series and wanted to migrate the slew of webpack code that I had into this.

Unfortunately, I keep seeing these errors when I run npm run build.

ERROR in bundle.js from UglifyJs
TypeError: Cannot read property 'sections' of null
    at new SourceMapConsumer (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/node_modules/webpack-core/node_modules/source-map/lib/source-map/source-map-consumer.js:24:21)
    at /Users/asrinivasan/Code/mea-culpa/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:62:23
    at Array.forEach (native)
    at Tapable.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:44:10)
    at Tapable.next (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/node_modules/tapable/lib/Tapable.js:69:14)
    at Tapable.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:136:4)
    at Tapable.applyPluginsAsync (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13)
    at Tapable.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/lib/Compilation.js:559:9)
    at Tapable.next (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11)
    at ExtractTextPlugin.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/index.js:227:4)
    at Tapable.applyPluginsAsync (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13)
    at Tapable.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/lib/Compilation.js:555:8)
    at Tapable.next (/Users/asrinivasan/Code/mea-culpa/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11)
    at ExtractTextPlugin.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/index.js:193:5)
    at /Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:119:25
    at /Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:24:16
    at ExtractTextPlugin.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/index.js:184:6)
    at /Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:119:25
    at /Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:24:16
    at ExtractTextPlugin.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/index.js:179:8)
    at /Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:111:13
    at Array.forEach (native)
    at _each (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:32:24)
    at Object.async.each (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:110:9)
    at ExtractTextPlugin.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/index.js:155:11)
    at /Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:111:13
    at Array.forEach (native)
    at _each (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:32:24)
    at Object.async.each (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:110:9)
    at ExtractTextPlugin.<anonymous> (/Users/asrinivasan/Code/mea-culpa/node_modules/hjs-webpack/node_modules/extract-text-webpack-plugin/index.js:152:10)

Here's how my package.json looks -

  "dependencies": {
    "axios": "^0.5.4",
    "express": "^4.13.1",
    "lodash": "^3.10.0",
    "react": "^0.13.3",
    "react-router": "^0.13.3"
  },
  "devDependencies": {
    "autoprefixer-core": "^5.2.1",
    "babel": "^5.8.3",
    "babel-core": "^5.8.3",
    "babel-loader": "^5.3.2",
    "css-loader": "^0.15.3",
    "file-loader": "^0.8.4",
    "hjs-webpack": "^2.11.0",
    "json-loader": "^0.5.2",
    "node-libs-browser": "^0.5.2",
    "postcss-loader": "^0.5.1",
    "react-hot-loader": "^1.2.8",
    "style-loader": "^0.12.3",
    "stylus-loader": "^1.2.1",
    "url-loader": "^0.5.6",
    "webpack": "^1.10.1",
    "webpack-dev-server": "^1.10.1",
    "yeticss": "^7.0.1"
  }

To note, I didnt install these manually (my npm version 2.9.0) - I just simply ran -

$ npm install --save-dev hjs-webpack`

I also tried various css-loader versions as noted here but to no avail. Any help?


Here's my webpack.config (if it helps)

var getConfig = require('hjs-webpack');
var isDev = process.env.NODE_ENV !== 'production';

module.exports = getConfig({
    in: 'js/App.js',
    out: 'build',
    isDev: isDev,
    clearBeforeBuild: true,
    html: false,
    output: {
        filename: "bundle.js",
        cssFilename: "styles.min.css"
    }
});

Note: This error is not generated in webpack-dev-server mode

hjs-webpack.js is generated instead of labelr.js

Following the tutorial on http://learn.humanjavascript.com/react-ampersand/setting-up-webpack, the tool generates a file called "hjs-webpack.2.2.1.js" whereas the video shows "labelr.1.0.0.js".

D:\project\labelr>npm run build

> [email protected] build D:\project\labelr
> set NODE_ENV=production&& webpack

Hash: 54d298f3d2231119f6ac
Version: webpack 1.9.5
Time: 925ms

               Asset       Size  Chunks             Chunk Names
hjs-webpack.2.2.1.js  292 bytes       0  [emitted]  main
          index.html  196 bytes          [emitted]  

   [0] multi main 28 bytes {0} [built]
    + 1 hidden modules

Am I doing something wrong?

(package.json)

{
  "name": "labelr",
  "version": "1.0.0",
  "description": "Github ticket label maintenance",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server",
    "build": "set NODE_ENV=production&& webpack",
    "deploy": "surge -p public -d oaklabelr.surge.sh"
  },
  "author": "atmo",
  "license": "ISC",
  "dependencies": {
    "autoprefixer-core": "^5.1.11",
    "babel": "^5.4.2",
    "babel-core": "^5.4.2",
    "babel-loader": "^5.1.0",
    "css-loader": "^0.12.1",
    "file-loader": "^0.8.1",
    "hjs-webpack": "^2.2.1",
    "json-loader": "^0.5.1",
    "node-libs-browser": "^0.5.0",
    "postcss-loader": "^0.4.3",
    "react": "^0.13.3",
    "react-hot-loader": "^1.2.7",
    "style-loader": "^0.12.2",
    "stylus-loader": "^1.1.1",
    "surge": "^0.12.0",
    "url-loader": "^0.5.5",
    "webpack": "^1.9.5",
    "webpack-dev-server": "^1.8.2",
    "yeticss": "^6.0.6"
  }
}

Document how to "extend" hjs-webpack

The issue of how to configure hjs-webpack with options that it doesn't use but webpack will use has come up a few times. #56 #52 #38

I'm leaning towards just documenting the current approach that hjs-webpack returns an object and manipulating that object to add other webpack configuration options is the way to go.

images not loaded since update to version 2.5

Hi

Thanks for this great tool. And please excuse if it turns out I'm wasting your time because I'm using webpack for the first time.

In my project (https://github.com/barbalex/gs) jpg and png images are loaded. I kept getting these error messages:
errormessages

So I added this in webpack.config.js in order to load images with file-loader:

config.module.loaders.push(
  {
    test: /\.(jpe?g|png|gif|svg|ico)$/i,
    loader: 'file'
  }
)

This worked nicely until I updated to hjs-webpack 2.5. With 2.5 no error messages are shown. But also: no images are shown.

Am I doing something completely wrong?

Or is this an issue with the update to version 2.5?

react module missing from package.json?

Was just going through the "Build an App with React and Ampersand" videos and I had to install the react module myself after installing hjs-webpack (but having to do that wasn't mentioned in the video) should react be listed in the package.json?

Static rendering with images and CSS

Did anybody manage to get the static rendering running when components include images and CSS?

If for example you include CSS in the HomePage of the prerendered-html-files example, you can't require it anymore in the webpack config.

I've tried to set up multiple entry points, so I can get HomePage to compile as well, so I might be able to require the processed JS file in the html callback. However, the file isn't written to disk at that point apparently.

Is there a good way to work around this?

Jade integration example

@HenrikJoreteg or @lukekarrys Can you give guys an example of how Jade could actually be integrated with hjs-webpack. I see the instructions but am not sure where I would place the Jade files and how I would include them in my project.

Thanks much!

cjsx doesn't get react-hot

if (isInstalled('react-hot-loader') && config.spec.devServer.hot) {
      config.module.loaders[0].loaders.unshift('react-hot')
    }

only adds react-hot to the babel loader. I need to add it to the cjsx and cs loaders too. I'm done for the day, but I plan on somehow tackling this tomorrow.

Proposed alternative to detecting installed packages

What is the opinion in this project on automatically installing packages for a user based on the hjs-webpack config? For me personally, having to install the loaders and plugins I want to use and then having them detected feels a little hacky.

And when I decide I want to use stylus, for example, it forces me to know implementation details (I also need to install css-loader, postcss-loader, and style-loader). I feel like ideally, a user should only have to answer the question, "What technologies do I want to use?" and there should be an explicit way of answering.

So here's a proposed alternative config:

var getConfig = require('hjs-webpack');

module.exports = getConfig({
  in: 'src/app.js',
  out: 'public',
  technologies: {
     js: [ 'babel', 'json', 'livescript', 'typescript' ],
     css: [ 'scss', 'stylus', 'autoprefixer' ],
     html: [ 'jade' ],
     fonts: true,
     images: true
  },
  vendor: [ 'yeticss', 'bootstrap' ]
});

Under the hood, hjs-webpack would worry about installing the necessary packages, figuring out what's a loader vs a plugin, etc. And I'd even argue that packages like autoprefixer and the url-loader for fonts and images should be active by default. The url-loader is 1MB and although autoprefixer is 7MB, I cannot think of a project where it wouldn't be useful.

The main reason I wouldn't want all of these optional loaders and plugins installed by default, hence completely eliminating the tech config, is file size - and I'm mostly looking at babel and babel-core: 36MB total. The other reason is with this syntax, webpack.config.js now becomes useful documentation on the technology stack in the project.

And as an added side effect, the documentation for hjs-webpack itself becomes much simpler and more intuitive. Want to use a technology or include a vendor package? Just say its name!

One downside is that for languages like TypeScript, where there are three popular loaders, we'd have to choose a default to support. I personally don't see that as a problem though, as we could also allow people to name specific loaders, instead of just the language, by using the full name of the loader (e.g. typescript-loader, ts-loader, or awesome-typescript-loader).

So people already very familiar with Webpack who might be used to naming specific loaders can and those less familiar that just want to quickly configure a build process can name technologies.

Thoughts?

hjs-dev-server: command not found

Thanks @HenrikJoreteg for your work!

I was trying to run the examples after following the installation instructions, but no matter what I try, running npm run start will always result in

sh: hjs-dev-server: command not found

what am I missing here?

This is on a Mac with Node v4.2.2 and npm v3.5.3 and hjs-webpack 6.1.0.
EDIT: using webpack-dev-server in the scripts section solves the problem, could you hint on that in the docs?

Multiple entrypoints?

Hello and thank you for sharing this "webpack" with the rest of us,
Does hjs-webpack allow for Multiple javascript entrypoints?
See explanation below:
https://github.com/petehunt/webpack-howto#7-multiple-entrypoints

Thanks a million

PS: I tried to play with the config after it's returned by:

var getConfig = require('hjs-webpack')
var hjsconfig = getConfig({ in: 'src/app.js', out: 'public' //....
// In here Code Manipulating hjsconfig
module.exports = hjsconfig;

But I could not make it work.

v5.2 breaks Glyphicons in my projects

After updating from v5.1 to v5.2 I get these errors:

Failed to decode downloaded font: data:application/octet-stream;base64,bW9kdWxlLmV4cG9ydHMgPSBfX3dlYnBhY2tfcHVibGljX3BhdGhfXyArICI0NDhjMzRhNTZkNjk5YzI5MTE3YWRjNjRjNDNhZmZlYi53b2ZmMiI7
login:1 OTS parsing error: invalid version tag
login:1 Failed to decode downloaded font: data:application/font-woff;base64,bW9kdWxlLmV4cG9ydHMgPSBfX3dlYnBhY2tfcHVibGljX3BhdGhfXyArICJmYTI3NzIzMjdmNTVkODE5ODMwMWZkYjhiY2ZjODE1OC53b2ZmIjs=
login:1 OTS parsing error: invalid version tag
login:1 Failed to decode downloaded font: data:application/x-font-ttf;base64,bW9kdWxlLmV4cG9ydHMgPSBfX3dlYnBhY2tfcHVibGljX3BhdGhfXyArICJlMThiYmY2MTFmMmEyZTQzYWZjMDcxYWEyZjRlMTUxMi50dGYiOw==
login:1 OTS parsing error: invalid version tag

and the Glyphicons are not showing.
If I set hjs-webpack back to v5.1 everything works.

Webpack config ist like this:

{test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff'},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file'},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml'}

These are the two projects where this happened:
https://github.com/barbalex/bb
https://github.com/barbalex/ae

I first opened an issue here: bline/bootstrap-webpack#20 but then I realized updating hjs-webpack seems to cause it.

Do I have an error in my code that only surfaces now or is there an issue in hjs-webpack?

Can't change file names of octicon's eot, svg, ttf and woff file.

Hi! I use octiocon.

import octicons from 'octicons/octicons/octicons.css'

Then, below files were generated by 'npm run deploy'.

  • 18c1afab3ad6a4a7261c466f4d494226.woff
  • 203938579eb80c78dc27a93fcfff4db1.svg
  • 443065e3eb9076e04666d0c6cc815bff.eot
  • eef9e4cfc53d5b60fdd1fc69a0e54a09.ttf

I want to change these md5 file names to normal.

How can I set?

hostname not working

I'm getting this error only when trying to use a hostname in webpack.config.js. I think it's possibly to do with the path to the hostname not being defined. Does anybody have an idea of what's going wrong?

Here's the config:

var getConfig = require('hjs-webpack');

module.exports = getConfig({
    in: 'src/app.js',
    out: 'public',
    isDev: process.env.NODE_ENV !== 'production',
    hostname: 'testhost.local'  // if i remove this line, everything works
});

Here is the error that terminal is showing.

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: getaddrinfo ENOTFOUND
    at errnoException (dns.js:37:11)
    at Object.onanswer [as oncomplete] (dns.js:124:16)

Thanks

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.