From 28229ea954f92a5013e25aaea0d7831724c9ff56 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sat, 10 Jun 2017 15:34:10 +0200 Subject: [PATCH] Use webpack. --- package.json | 92 ++++++++++++++++++++++---------------- webpack.config.js | 109 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 37 deletions(-) create mode 100644 webpack.config.js diff --git a/package.json b/package.json index 979a075..1808b3a 100644 --- a/package.json +++ b/package.json @@ -4,42 +4,60 @@ "repository": "https://git.lahouze.org/xals/accountant", "license": "AGPL-1.0", "devDependencies": { - "connect-logger": "0.0.1", - "connect-proxy-layer": "^0.1.2", - "eslint": "^3.7.1", - "eslint-config-angular": "^0.5.0", - "eslint-config-google": "~0.6", - "eslint-plugin-angular": "^1.4.1", - "eslint-plugin-html": "^1.5.3", - "eslint-plugin-jquery": "^1.0.1", - "eslint-plugin-promise": "^3.0.0", - "eslint-plugin-security": "^1.2.0", - "eslint-plugin-this": "^0.1.4", - "grunt": "~1.0", - "grunt-bg-shell": "^2.3.1", - "grunt-contrib-clean": "~1.0", - "grunt-contrib-concat": "~1.0", - "grunt-contrib-connect": "~1.0", - "grunt-contrib-csslint": "^2.0.0", - "grunt-contrib-cssmin": "~1.0", - "grunt-contrib-less": "^1.4.0", - "grunt-contrib-uglify": "~2.0", - "grunt-contrib-watch": "~1.0", - "grunt-copy": "^0.1.0", - "grunt-eslint": "~19.0", - "grunt-filerev": "^2.3.1", - "grunt-flake8": "^0.1.3", - "grunt-htmllint": "^0.2.7", - "grunt-include-source": "~1.0", - "grunt-jsonlint": "^1.1.0", - "grunt-lesslint": "^3.2.0", - "grunt-newer": "~1.1", - "grunt-ng-annotate": "~2.0", - "grunt-shell": "~2.0", - "grunt-usemin": "^3.1.1", - "grunt-wiredep": "~3.0", - "load-grunt-configs": "~1.0", - "load-grunt-tasks": "^3.2.0", - "time-grunt": "^1.3.0" + "babel-core": "^6.25.0", + "babel-eslint": "^7.2.3", + "babel-loader": "^7.0.0", + "bootstrap-webpack": "^0.0.6", + "css-loader": "^0.28.4", + "eslint": "^3.19", + "eslint-config-angular": "^0.5", + "eslint-config-webpack": "^1.2.3", + "eslint-friendly-formatter": "^3.0.0", + "eslint-loader": "^1.7.1", + "eslint-plugin-angular": "^2.4", + "eslint-plugin-html": "^2.0", + "eslint-plugin-jquery": "^1.2", + "eslint-plugin-promise": "^3.5", + "eslint-plugin-security": "^1.3", + "eslint-plugin-this": "^0.2", + "extract-text-webpack-plugin": "^2.1.2", + "file-loader": "^0.11.2", + "html-loader": "^0.4.5", + "html-webpack-plugin": "^2.28.0", + "htmllint-loader": "^1.3.8", + "imports-loader": "^0.7.1", + "less": "^2.7.2", + "less-loader": "^4.0.4", + "ngtemplate-loader": "^2.0.0", + "style-loader": "^0.18.2", + "url-loader": "^0.5.8", + "webpack": "^2.6.1", + "webpack-dev-server": "^2.4.5" + }, + "dependencies": { + "angular": "^1.6", + "angular-http-auth": "^1.5", + "angular-messages": "^1.6", + "angular-resource": "^1.6", + "angular-route": "^1.6", + "angular-strap": "^2.3.12", + "angular-ui-bootstrap": "^2.5", + "angular-ui-notification": "^0.3", + "angular-xeditable": "^0.8", + "base64util": "^1.0.2", + "bootbox": "^4.4.0", + "bootstrap": "^3.3.7", + "bootstrap-additions": "^0.3.1", + "font-awesome": "^4.7.0", + "highcharts-ng": "^1.1", + "highstock-release": "^5.0.12", + "jquery": "^3.2", + "meanie-angular-storage": "^1.3.1", + "moment": "^2.18", + "ngbootbox": "^0.2.0" + }, + "scripts": { + "build": "webpack --config webpack.config.js", + "dev": "webpack-dev-server --debug --devtool eval --config webpack.config.js --progress --colors --hot --content-base build" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..005c3c5 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,109 @@ +/* jshint esversion: 6 */ +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +module.exports = { + context: path.resolve(__dirname, 'accountant-ui'), + entry: './js/app.js', + devtool: 'source-map', + module: { + rules: [{ + enforce: 'pre', + test: /webpack\.config\.js$/, + include: path.resolve(__dirname), + loader: 'eslint-loader', + options: { + useEslintrc: false, + formatter: require('eslint-friendly-formatter'), + emitWarning: true, + emitError: true, + failOnWarning: true, + failOnError: true, + baseConfig: 'webpack', + rules: { + indent: ['error', 4] + }, + }, + }, { + // Javascript + enforce: 'pre', + test: /\.jsx?$/, + include: path.resolve(__dirname, 'accountant-ui'), + exclude: /(node_modules|bootstrap)/, + loader: 'eslint-loader', + options: { + useEslintrc: false, + formatter: require('eslint-friendly-formatter'), + emitWarning: false, + emitError: true, + failOnWarning: false, + failOnError: true, + baseConfig: 'angular', + rules: { + indent: ['error', 4] + }, + plugins: [ + 'angular', + 'html', + 'security', + 'this', + 'jquery', + 'promise' + ] + }, + }, { + test: /\.html$/, + exclude: /views/, + enforce: 'pre', + loader: 'htmllint-loader' + }, { + test: /\.jsx?$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, { + test: /\.html$/, + use: [ + 'ngtemplate-loader?relativeTo=/accountant-ui/accountant-ui', + 'html-loader' + ] + }, { + test: /\.less$/, + use: [ + 'style-loader', + 'css-loader', + 'less-loader', + ] + }, { + test: /\.css$/, + use: [ + 'style-loader', + 'css-loader', + ] + }, { + test: /\.(png|woff|woff2|eot|ttf|svg)$/, + loader: 'url-loader?limit=100000' + }] + }, + plugins: [ + new HtmlWebpackPlugin({ + title: 'Accountant', + template: 'index.ejs' + }), + ], + output: { + path: path.resolve(__dirname, 'build'), + filename: 'js/bundle.js', + //publicPath: 'js' + }, + devServer: { + proxy: { + '/api': { + target: 'http://localhost:5000', + secure: false + } + }, + hot: true, + noInfo: false, + quiet: false, + } +};