Tjorriemorrie
Tjorriemorrie

Reputation: 17282

No build file for webpack-dev-server

webpack.config.js

var path = require('path');
var webpack = require('webpack');

module.exports = {
    entry: path.resolve(__dirname, 'assets/jsx/Index.jsx'),
    output: {
        path: path.resolve(__dirname, 'gae/src/static/build'),
        filename: 'besetfree.js'
    },
    plugins: [
        new webpack.NoErrorsPlugin()
    ],
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                loaders: ['react-hot', 'babel?cacheDirectory,presets[]=react,presets[]=es2015']
            },
            {
                test: /\.less$/,
                loader: 'style!css!less'
            }, // use ! to chain loaders
            {
                test: /\.css$/,
                loader: 'style!css'
            }
        ]
    }
};

I run this npm command:

"start": "webpack-dev-server --port 9898 --devtool eval --progress --colors --content-base gae/src --hot --inline",

It builds fine:

> [email protected] start /Users/me/code/besetfree
> webpack-dev-server --port 9898 --devtool eval --progress --colors --content-base gae/src --hot --inline

 70% 1/1 build moduleshttp://localhost:9898/
webpack result is served from /
content is served from /Users/me/code/besetfree/gae/src
Hash: 1abe8a20ea579ccbfa3a
Version: webpack 1.12.12
Time: 4361ms
       Asset     Size  Chunks             Chunk Names
besetfree.js  1.51 MB       0  [emitted]  main
chunk    {0} besetfree.js (main) 1.31 MB [rendered]

But there is no file at http://localhost:9898/static/build/:

enter image description here

Any help please?

Upvotes: 1

Views: 956

Answers (1)

Joe Clay
Joe Clay

Reputation: 35797

You need to add a publicPath to your Webpack config in order to let the server know what URL to serve things from.

output: {
    path: path.resolve(__dirname, 'gae/src/static/build'),
    publicPath: "static/build",
    filename: 'besetfree.js'
},

Upvotes: 1

Related Questions