Update development environment (Webpack) #1

Merged
raucao merged 1 commits from chore/update_dev_env into master 2021-09-04 11:46:25 +00:00
3 changed files with 2596 additions and 22 deletions

2565
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,10 @@
"description": "Stores chat messages in daily archive files",
"main": "./dist/build.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "NODE_ENV=production webpack",
"dev": "webpack -w",
"build": "NODE_ENV=production webpack -p",
"start": "npm run dev",
"test": "echo \"Error: no test specified\" && exit 1",
"version": "npm run build && git add dist/"
},
"author": "Kosmos Contributors <mail@kosmos.org> (https://kosmos.org)",
@ -16,9 +17,10 @@
"url": "https://github.com/67P/remotestorage-module-chat-messages.git"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.18.0",
"webpack": "^1.13.2"
"@babel/core": "^7.14.8",
"@babel/preset-env": "^7.14.9",
"babel-loader": "^8.2.2",
"webpack": "^5.48.0",
"webpack-cli": "^4.8.0"
}
}

View File

@ -1,24 +1,31 @@
var webpack = require('webpack');
var isProd = (process.env.NODE_ENV === 'production');
// minimize only in production
var plugins = isProd ? [new webpack.optimize.UglifyJsPlugin({minimize: true })] : []
/* global __dirname */
const isProd = (process.env.NODE_ENV === 'production');
const path = require('path');
module.exports = {
entry: './index.js',
// source map not in production
devtool: !isProd && 'source-map',
entry: ['./index.js'],
output: {
filename: __dirname + '/dist/build.js',
libraryTarget: 'umd'
path: path.resolve(__dirname, 'dist'),
filename: 'build.js',
library: 'ChatMessages',
libraryTarget: 'umd',
libraryExport: 'default'
},
mode: isProd ? 'production' : 'development',
devtool: isProd ? 'source-map' : 'eval-source-map',
module: {
loaders: [
{ test: /\.js$/, exclude: '/node_modules|dist/', loader: 'babel?presets[]=es2015' },
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
]
},
resolve: {
extensions: ['', '.js']
},
plugins: plugins
// plugins: plugins
};