Skip to content
Snippets Groups Projects
Commit 5c684ef0 authored by Hermann's avatar Hermann
Browse files

add webpack and node structure

parent 4a865bf7
No related branches found
No related tags found
No related merge requests found
module.exports = {
"extends": "airbnb-base",
"plugins": [
"import"
],
"env": {
"browser": true,
},
"rules": {
"no-console": 0,
"class-methods-use-this": 0,
"prefer-destructuring": 1,
"no-underscore-dangle": 0,
}
};
{
"name": "amiv-admintools",
"version": "0.0.1",
"description": "Admintools to access the AMIV API.",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --hot --inline",
"build": "webpack -p --config webpack.config.prod.js",
"lint": "eslint src/**"
},
"repository": {
"type": "git",
"url": "git@gitlab.ethz.ch:amiv/amiv-admintool.git"
},
"author": "Hermann Blum et al",
"dependencies": {
"ajv": "^5.5.0",
"axios": "^0.17.1",
"babel": "^6.23.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"compression-webpack-plugin": "^1.0.1",
"file-loader": "^1.1.5",
"mithril": "^1.1.5",
"querystring": "^0.2.0",
"uglifyjs-webpack-plugin": "^1.0.1",
"webpack": "^3.8.1"
},
"devDependencies": {
"eslint": "^4.10.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-import": "^2.8.0",
"webpack-dev-server": "^2.9.3"
}
}
const publicPath = '/dist';
const config = {
context: `${__dirname}/src`, // `__dirname` is root of project
entry: './index.js',
output: {
path: `${__dirname}/dist`, // `dist` is the destination
filename: 'bundle.js',
},
// To run development server
devServer: {
contentBase: __dirname,
publicPath,
compress: true,
port: 9000,
hot: true,
index: 'index.html',
},
module: {
rules: [
{
test: /\.js$/,
enforce: "pre",
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
emitWarning: true // don't fail the build for linting errors
}
},
{
test: /\.js$/, // Check for all js files
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: { presets: ['env'] },
}],
},
{
test: /\.(png|jpe?g|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
publicPath,
},
},
],
},
],
},
devtool: 'eval-source-map', // Default development sourcemap
};
module.exports = config;
const webpack = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
// Start with dev config
const config = require('./webpack.config.js');
// Remove development server and code map
config.devServer = undefined;
config.devtool = '';
// Add optimization plugins
config.plugins = [
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8,
}),
];
module.exports = config;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment