1

webpack.config.jsContenu non de webpack est servi à partir de/dist

var HtmlWebpackPlugin = require('html-webpack-plugin'); 
const path = require('path'); 

module.exports = { 

entry:'./src/app.js', 
output:{ 
    path:path.join(__dirname, 'dist'), 
    filename:'app.bundle.js', 
    publicPath:'/dist/' 
}, 

, 
devServer: { 
    contentBase: path.join(__dirname, "dist"), 
    compress: true, 
    stats: "errors-only", 
    openPage: '', 
    port:9000, 
    open:true 
}, 
    plugins: [new HtmlWebpackPlugin({ 
    title:'Forum', 
    filename:'index.html' 
    //template:'./src/app.html' 
    })] 

} 

Ma structure du projet:

├── forum 
    │ └── dist 
      └── app.bundle.js 
    ├── src 
    │  ├── app.html 
    │  ├── app.js 
    ├── package.json 
    ├── webpack.config.js 

Package.json

"scripts": { 
    "dev": "webpack-dev-server -d " 
    } 

Version

Node: v8.3.0 
webpack :3.5.4 
webpack-dev-server: 2.7.1 

Quand je lance ma commande npm run dev

Sortie:

Project is running at http://localhost:9000/ 
webpack output is served from /dist/ 
Content not from webpack is served from /Users/me/Documents/forum/forum 

Je ne peux pas le contenu que je me manque quelque chose? Il me manque quelque chose? Il me manque quelque chose? Il me manque quelque chose? Il me manque quelque chose?

+2

Cochez cette case: https://stackoverflow.com/questions/42712054/content-not-from-webpack-is-served-from-foo –

Répondre

0

car vous avez spécifié le chemin public/dist/votre application est en cours de traitement au http://localhost:9000/dist/. Si vous voulez qu'il soit servi à partir du répertoire racine, supprimez l'attribut du chemin public sur votre sortie.