/** * @file Configuration de webpack. * Webpack prend tous les fichiers sources, les traduit si nécessaire et les rassemble en un bundle.js exécutable. * Cela permet de déployer directement le code produit par chaque commit * @author manifold */ const path = require('path'); const nodeExternals = require('webpack-node-externals'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const config = { entry: path.resolve(__dirname, 'src', 'index.ts'), output: { path: path.resolve(__dirname, 'build'), publicPath: '/assets/', filename: 'bundle.js' }, target: 'node', // allows using __dirname with the correct semantic (otherwise __dirname will return '/' regardless of file) node: { __dirname: true }, // Choose a style of source mapping to enhance the debugging process // https://webpack.js.org/configuration/devtool/ //devtool: 'inline-source-map', //TODO: in production, or if deemed too slow, remove this // do not bundle node_modules, nor secret config files externals: [ nodeExternals(), { ldapConfig: './ldap_config.json', credentialsConfig: './ldap_connexion_config.json' } ], resolve: { //enables users to leave off the extension when importing //e.g. import File from './path/to/file' vs. './path/to/file.js' extensions: ['.ts', '.js'] }, plugins: [ //Copies individual files or entire directories to the build directory new CopyWebpackPlugin([{ from: 'src/adminview/css', to: 'css' }, { from: 'src/adminview/views', to: 'views' }]) ], module: { rules: [{ test: /\.js$/, use: ['eslint-loader'] },{ test: /\.ts$/, use: ['ts-loader'], },{ test: /\.css$/, use: ['style-loader', 'css-loader'] },{ type: 'javascript/auto', test: /\.json$/, use: ['file-loader'] }, { test: /\.graphql?$/, use: [{ loader: 'webpack-graphql-loader', options: { // validate: true, // schema: "./path/to/schema.json", // removeUnusedFragments: true // etc. See "Loader Options" below } }] }, { test: /\.(png|jpg|ico)$/, use: { loader: 'url-loader?limit=8192' // loads files as base64 encoded URL if filesize is < limit // default fallback: file-loader } //use: ['file-loader'] }] }, }; module.exports = config;