1

I have following dev-server configuration

devServer: {
    port: 3000,
    host: '0.0.0.0',
    watchOptions: {
        aggregateTimeout: 300,
        poll: 1000,
    },
    compress: true,
    inline: true,
    contentBase: BUILD_PATH,
    historyApiFallback: true,
}

Where

BUILD_PATH = path.resolve(__dirname, '../build/webapp')

The problem is that ../build/webapp folder is empty when dev-server started. As result application loading fine (index.html, bundle.js) but cannot load any fonts or other resources which should be located in assets subfolder.

And if i run just webpack - everything appears in that folder. After webpack i can start dev-server and everything good.

Dev-server logs:

    Project is running at http://0.0.0.0:3000/
    webpack output is served from /
    Content not from webpack is served from D:\Development\Projects\myproject\build\webapp
    404s will fallback to /index.html 
10% building modules 5/8 modules 3 active
     ...oject\webapp\node_modules\url\url.js(node:5560) 
 63% building modules 746/839 modules 93 active ...node_modules\lodash-es\_freeGlob
    al.js

Any ideas ?

1 Answer 1

3

The webpack devserver mode build and handle result in memory and does not save to disk. It save them to disk in build mode (not in devserver mode).

Typical solution is do runing webpack in watch mode in parallel to devserver:

webpack -w

Also there write-file-webpack-plugin for devserver is used some people:

Sign up to request clarification or add additional context in comments.

3 Comments

How can i force dev-server to include fonts that are loaded by webpack 'url-loader' ? (they are seperate woff files in assets folder if i running webpack)
I can see them in dev-server logs ` /assets/fonts/source-sans-pro-v9-latin-700italic.woff2 13.7 kB [emitted] /assets/fonts/inconsolata-v15-latin_latin-ext-700.woff 35.9 kB [emitted]... ` but cant access them via browser. 404 error
You can access them from browser from webpack dev server url:port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.