Backing up and sharing my development configuration, using Webpack, Babel, ESLint, Karma, Typescript...
- devtool cheap-module-source-map source-map
- plugins uglifyjs-webpack-plugin
- loaders babel-loader eslint-loader
'use strict'
const uglifyjs = require('uglifyjs-webpack-plugin')
const DEV_ENV = process.env.NODE_ENV === 'dev'
const config = {
context: __dirname + '/src',
entry: './app.js',
output: {
path: __dirname + '/dist',
filename: '[name].bundle.js',
},
devtool: DEV_ENV ? 'cheap-module-source-map' : 'source-map',
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'eslint-loader',
},
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
},
},
],
},
plugins: [],
}
if (!dev) {
config.plugins.push(new uglifyjs({
sourceMap: true,
}))
}
module.exports = config
Nothing fancy here!
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]
]
}
Using the awesome Javascript Standard :)
{
"extends": "standard"
}
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-env": "^1.6.0",
"eslint": "^4.4.1",
"eslint-config-standard": "^10.2.1",
"eslint-loader": "^1.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"uglifyjs-webpack-plugin": "^0.4.6",
"webpack": "^3.5.3"
}
leonardo@dev:~/$ npm i -D webpack babel-core babel-loader babel-preset-env eslint-loader eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint eslint-config-standard uglyfyjs-webpack-plugin
"scripts": {
"dev": "NODE_ENV=dev webpack -d --watch",
"build": "NODE_ENV=prod webpack -p",
"test": "NODE_ENV=test karma"
},
This project is licensed under the MIT License - see the LICENSE.md file for details