webpack: Add a configuration for production bundle

This commit is contained in:
Sam Vervaeck 2020-06-13 19:27:39 +02:00
parent 7aef97334b
commit 4dcc561a73
2 changed files with 31 additions and 1 deletions

View file

@ -9,7 +9,7 @@
},
"scripts": {
"watch": "webpack --watch --config webpack.dev.js",
"prepare": "webpack --config webpack.dev.js",
"prepare": "webpack --config webpack.prod.js",
"test": "node lib/bin/bolt-test.js compare",
"generate-ast": "tsastgen src/ast-spec.ts:src/ast.ts",
"update-lkg": "node lib/bin/bolt-test.js create-snapshot lkg"

30
webpack.prod.js Normal file
View file

@ -0,0 +1,30 @@
const webpack = require("webpack");
const path = require("path");
module.exports = {
target: 'node',
mode: 'development',
entry: {
'bolt': './src/bin/bolt.ts',
'bolt-test': './src/bin/bolt-test.ts',
},
output: {
filename: 'bin/[name].js',
path: path.resolve(__dirname, 'build'),
},
resolve: {
extensions: [".ts", ".js"],
},
plugins: [
new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }),
],
devtool: 'source-map',
module: {
rules: [
{ test: /\.ts$/, loader: "ts-loader", options: { transpileOnly: true } },
{ test: /\.m?js$/, exclude: /node_modules/, loader: 'babel-loader' },
]
}
};