Giter Site home page Giter Site logo

Comments (7)

jhnns avatar jhnns commented on July 23, 2024

It looks like you're not bundling anything. After the line Asset Size Chunks Chunk Names there are usually all modules listed that have been added to the bundle.

Is there a webpack.config.js file in your cwd?

from webpack-dev-server.

robrichard avatar robrichard commented on July 23, 2024

There is a webpack.config.js in my cwd. I added the option webpack-dev-server --config webpack.conf.js and it is running and building my files now. I can't figure out where to get the compiled assets from:

    entry: {
        'dashboard': '/Users/rob/projects/myProject/src/js/entries/dashboard.js',
        'internal/administrator': '/Users/rob/projects/myProject/src/js/entries/internal/administrator.js',
        ...
    },
    output: {
        filename: './public/compiled/js/[name].js'

Ideally I'd like to run the dev-server on port 8080 and access my assets in my script tag like this:

http://localhost:8080/compiled/js/dashboard.js
http://localhost:8080/compiled/js/internal/administrator.js

from webpack-dev-server.

jhnns avatar jhnns commented on July 23, 2024

That's where the --content-base comes in. Just run webpack-dev-server --config webpack.conf.js --content-base /compiled/js.

If you name your webpack config webpack.config.js you don't need to specify it via the command-line. Webpack looks for a webpack.config.js in the cwd by default.

Please note also, that you need to run webpack-dev-server in the public-folder if you want the webpack-dev-server to serve all files under public.

from webpack-dev-server.

sokra avatar sokra commented on July 23, 2024

You need a config like this:

...
output: {
  path: __dirname + "/public",
  filename: "compiled/js/internal/[name].js"
}

and run it with webpack-dev-server --content-base public

Now you can access any file in public and any file that would be there:

http://localhost:8080/compiled/js/dashboard.js

from webpack-dev-server.

robrichard avatar robrichard commented on July 23, 2024

Thank you both so much for your help. I'm able to access the files now using @sokra's config example.

I am still facing one problem though. I am using webpack to compile the assets for a large multi-page site with about 15 entry files. It appears that when one file is edited, all of the entries are rebuilt, and loading the asset blocks for about 20 seconds until all of the assets are recompiled. The documentation mentions that incremental rebuilds are possible. Is there an option I need to use to enable this? I tried both the cache and lazy options.

When we were using watchify, it would take about 20 seconds to initially build all of the files, and about 2 seconds for incremental rebuilds when a single file is edited.

Thanks again for your help.

from webpack-dev-server.

jhnns avatar jhnns commented on July 23, 2024

With plain webpack incremental builds are usually available via the cache- and watch-option. Enable both in your webpack.config.js and run webpack --config path/to/webpack.config.js. Rebuilds should be way faster now.

The webpack-dev-server doesn't require the watch-option necessarily since it is designed for a development environment. But it seems like the watch-mode is only entered if options.lazy != true (which is probably a bug @sokra?)

from webpack-dev-server.

robrichard avatar robrichard commented on July 23, 2024

Thanks so much for all your help. With @sokra's latest changes, everything is working as expected.

from webpack-dev-server.

Related Issues (20)

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.