Webpack 2.2.0
I include/exclude file/folder in my config, but webpack keeps bundling that was excluded:
the folder structure
src/
index.js // entry point
server/
test.js // file for testing
build/
webpack.config.js
const path = require('path')
const SRC = path.resolve(process.cwd(), './src')
const BUILD = path.resolve(process.cwd(), './build')
module.exports = {
context: SRC,
entry: {
main: './'
},
output: {
path: BUILD,
filename: '[name].bundle.js',
publicPath: '/assets/'
},
module: {
rules: [{
test: /\.jsx?/,
include: SRC,
exclude: path.resolve(process.cwd(), './server’), // even explicit excluding changes nothing
loader: 'babel-loader'
}]
}
}
./src/index.js
import func from ‘../server/test.js’ // this must not be imported
func() // working
./server/test.js
export default function () { console.log(`I’m in the bundle`) } // this is being executed
I see the message in the browser console.