Skip to content

Instantly share code, notes, and snippets.

@h1romas4
Last active April 7, 2020 07:37
Show Gist options
  • Save h1romas4/79fd7ed390ff65a8873c2c8e51c44e1d to your computer and use it in GitHub Desktop.
Save h1romas4/79fd7ed390ff65a8873c2c8e51c44e1d to your computer and use it in GitHub Desktop.
express だけ除外してバンドルする node 向け webpack.config.js
const path = require('path');
module.exports = {
devtool: "source-map",
mode: 'production',
target: 'node',
externals: function (context, request, callback) {
// use express in server install
// npm install express
// NODE_PATH=`npm root -g` node dist/app-bundle.js
if (request === 'express') {
return callback(null, 'commonjs ' + request);
}
callback();
},
entry: {
app: './src/app.js',
},
output: {
filename: 'app-bundle.js',
path: path.join(__dirname, '/dist'), // eslint-disable-line
},
optimization: {
minimize: false
},
plugins: [
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
presets: [[
'@babel/preset-env', {
"targets": {
"node": "current"
}
}
]]
}
}]
}
]
},
resolve: {
extensions: ['.js'],
modules: [
"node_modules"
]
},
performance: {
hints: false
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment