Im trying to organize a webpack 2 template for my personal projects with webpack-dev-server
and run it with the npm commands, but i'm getting this error:
Configuration file found but no entry configured.
It's weird because the entry is defined and i tested the resolved route, it's fine, so here is my webpack config, the command to run it and the file to configure the loaders:
webpack.config.dev.js
const path = require('path');
const fs = require('fs');
const configs = require('./dev-wpk-conf');
const HtmlPlugin = require('html-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const webpack = require('webpack');
const dirPath = fs.realpathSync(process.cwd());
const config = {
entry: {
bundle: path.resolve(dirPath, '../src/index.js'),
vendor: configs.vendor
},
output: {
path: path.resolve(dirPath, '../dist'),
filename: '[name].[hash].js'
},
devServer: {
port: 3030
},
module: {
rules: [
configs.jsonLoader,
configs.babelLoader,
configs.imgLoader,
configs.sassLoader
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ names: ['vendor', 'manifest'] }),
new HtmlPlugin({ template: './src/index.html' }),
new Dotenv()
]
}
dev-wpk-conf.js (the loaders):
const vendor = [
'react',
'react-dom',
'react-redux',
'react-router',
'redux',
'redux-form',
'redux-thunk',
'redux-devtools-extension'
];
const jsonLoader = {
test: /\.json$/,
loader: 'json-loader'
};
const babelLoader = {
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['babel-preset-env', 'react']
}
};
const imgLoader = {
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{ loader: 'url-loader', options: { limit: 40000 } },
'image-webpack-loader'
]
};
const sassLoader = {
test: /\.(scss|sass)$/,
use: [
{ loader: 'css-loader' },
{ loader: 'sass-loader' }
],
fallback: 'style-loader'
};
module.exports = {
vendor,
jsonLoader,
babelLoader,
imgLoader,
sassLoader
};
NPM scripts:
"clean": "rimraf dist",
"serve": "yarn clean && webpack-dev-server --config ./config/webpack.config.dev.js"
The folder structure:
config/
dev-wpk-conf.js
prod-wpk-conf.js
webpack.config.dev.js
webpack.config.prod.js
node_modules/
...
src/
index.js
// the app code
package.json
.env
//rc files
So, why exactly i'm getting this error? I'm not an expert but the entry is defined and the resolved path (again) is correct.
Any hint?
via Nano
No comments:
Post a Comment