You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
961 B
45 lines
961 B
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
const nodeExternals = require('webpack-node-externals');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const {
|
|
__DEV__,
|
|
backendBuildPath: buildPath,
|
|
backendSrcPath: srcPath,
|
|
} = require('./environment');
|
|
|
|
const alias = {
|
|
'/environment': path.resolve(__dirname, 'environment.js'),
|
|
};
|
|
fs.readdirSync(srcPath).forEach(name => {
|
|
alias['/' + name] = path.resolve(srcPath, name);
|
|
});
|
|
|
|
module.exports = {
|
|
target: 'node',
|
|
node: {
|
|
__dirname: true,
|
|
},
|
|
entry: srcPath,
|
|
externals: [nodeExternals()],
|
|
resolve: {
|
|
modules: [srcPath],
|
|
extensions: ['.js'],
|
|
alias,
|
|
},
|
|
output: {
|
|
path: buildPath,
|
|
filename: 'index.js',
|
|
libraryTarget: 'umd',
|
|
},
|
|
module: {
|
|
rules: [
|
|
{ test: /\.js$/, use: 'babel-loader', include: srcPath },
|
|
],
|
|
},
|
|
plugins: [
|
|
new CleanWebpackPlugin([buildPath]),
|
|
],
|
|
mode: __DEV__ ? 'development' : 'production',
|
|
}; |