You've already forked gnatdashboard
mirror of
https://github.com/AdaCore/gnatdashboard.git
synced 2026-02-12 12:30:42 -08:00
Use es6 target for typescript Use proper node modules versions Remove dll budles plugin: this plugin was a shortcut to generate vendor bundle + reference it in the bundled app, but in fact it was forcing the vendor entry point name to "vendor" when it should have been the same as the name defined in the bundle-manifest.json: vendor_lib. Hence the 'vendor_lib' not defined. So make it work, do: > npm install > npm run build:dev > npm run server:dev (after having put the data dir content in /dist/data) And it requires at least node 8.0.0 TO-DO: the final js files are a bit under 2M, some minification might be good to reduce it a bit, but as it's a loaded locally, it's no big deal. Part of S913-015 Change-Id: I9c37f86e54adeed938f684f5a8e23646e93c0291
210 lines
5.8 KiB
JavaScript
210 lines
5.8 KiB
JavaScript
/**
|
|
* @author: @AngularClass
|
|
*/
|
|
const webpack = require('webpack');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const helpers = require('./helpers');
|
|
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
|
|
const webpackMergeDll = webpackMerge.strategy({plugins: 'replace'});
|
|
const commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
|
|
const path = require('path');
|
|
|
|
/**
|
|
* Webpack Plugins
|
|
*/
|
|
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
|
|
const DefinePlugin = require('webpack/lib/DefinePlugin');
|
|
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin');
|
|
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
|
|
|
|
/**
|
|
* Webpack Constants
|
|
*/
|
|
const ENV = process.env.ENV = process.env.NODE_ENV = 'development';
|
|
const HOST = process.env.HOST || 'localhost';
|
|
const PORT = process.env.PORT || 3000;
|
|
const HMR = helpers.hasProcessFlag('hot');
|
|
const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
|
|
host: HOST,
|
|
port: PORT,
|
|
ENV: ENV,
|
|
HMR: HMR
|
|
});
|
|
|
|
|
|
const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin;
|
|
|
|
/**
|
|
* Webpack configuration
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#cli
|
|
*/
|
|
module.exports = function (options) {
|
|
return webpackMerge(commonConfig({env: ENV}), {
|
|
|
|
/**
|
|
* Developer tool to enhance debugging
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#devtool
|
|
* See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
|
|
*/
|
|
devtool: 'cheap-module-source-map',
|
|
|
|
/**
|
|
* Options affecting the output of the compilation.
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#output
|
|
*/
|
|
output: {
|
|
|
|
/**
|
|
* The output directory as absolute path (required).
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#output-path
|
|
*/
|
|
path: helpers.build('dist'),
|
|
|
|
/**
|
|
* Specifies the name of each output file on disk.
|
|
* IMPORTANT: You must not specify an absolute path here!
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#output-filename
|
|
*/
|
|
filename: '[name].bundle.js',
|
|
|
|
/**
|
|
* The filename of the SourceMaps for the JavaScript files.
|
|
* They are inside the output.path directory.
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
|
|
*/
|
|
sourceMapFilename: '[file].map',
|
|
|
|
/** The filename of non-entry chunks as relative path
|
|
* inside the output.path directory.
|
|
*
|
|
* See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
|
|
*/
|
|
chunkFilename: '[id].chunk.js',
|
|
|
|
library: 'ac_[name]',
|
|
libraryTarget: 'var',
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
/*
|
|
* css loader support for *.css files (styles directory only)
|
|
* Loads external css styles into the DOM, supports HMR
|
|
*
|
|
*/
|
|
{
|
|
test: /\.css$/,
|
|
use: ['style-loader', 'css-loader'],
|
|
include: [helpers.root('src', 'styles')]
|
|
},
|
|
|
|
/*
|
|
* sass loader support for *.scss files (styles directory only)
|
|
* Loads external sass styles into the DOM, supports HMR
|
|
*
|
|
*/
|
|
{
|
|
test: /\.scss$/,
|
|
use: ['style-loader', 'css-loader', 'sass-loader'],
|
|
include: [helpers.root('src', 'styles')]
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
/**
|
|
* Plugin: DefinePlugin
|
|
* Description: Define free variables.
|
|
* Useful for having development builds with debug logging or adding global constants.
|
|
*
|
|
* Environment helpers
|
|
*
|
|
* See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
|
|
*/
|
|
// NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
|
|
new DefinePlugin({
|
|
'ENV': JSON.stringify(METADATA.ENV),
|
|
'HMR': METADATA.HMR,
|
|
'process.env': {
|
|
'ENV': JSON.stringify(METADATA.ENV),
|
|
'NODE_ENV': JSON.stringify(METADATA.ENV),
|
|
'HMR': METADATA.HMR,
|
|
}
|
|
}),
|
|
/**
|
|
* Plugin: AddAssetHtmlPlugin
|
|
* Description: Adds the given JS or CSS file to the files
|
|
* Webpack knows about, and put it into the list of assets
|
|
* html-webpack-plugin injects into the generated html.
|
|
*
|
|
* See: https://github.com/SimenB/add-asset-html-webpack-plugin
|
|
*/
|
|
/**
|
|
* Plugin: NamedModulesPlugin (experimental)
|
|
* Description: Uses file names as module name.
|
|
*
|
|
* See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb
|
|
*/
|
|
// new NamedModulesPlugin(),
|
|
|
|
/**
|
|
* Plugin LoaderOptionsPlugin (experimental)
|
|
*
|
|
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
|
|
*/
|
|
new LoaderOptionsPlugin({
|
|
debug: true,
|
|
options: {
|
|
|
|
}
|
|
})
|
|
],
|
|
|
|
/**
|
|
* Webpack Development Server configuration
|
|
* Description: The webpack-dev-server is a little node.js Express server.
|
|
* The server emits information about the compilation state to the client,
|
|
* which reacts to those events.
|
|
*
|
|
* See: https://webpack.github.io/docs/webpack-dev-server.html
|
|
*/
|
|
devServer: {
|
|
port: METADATA.port,
|
|
host: METADATA.host,
|
|
historyApiFallback: true,
|
|
publicPath: '/',
|
|
watchOptions: {
|
|
aggregateTimeout: 300,
|
|
poll: 1000
|
|
}
|
|
},
|
|
|
|
/*
|
|
* Include polyfills or mocks for various node stuff
|
|
* Description: Node configuration
|
|
*
|
|
* See: https://webpack.github.io/docs/configuration.html#node
|
|
*/
|
|
node: {
|
|
global: true,
|
|
crypto: 'empty',
|
|
process: true,
|
|
module: false,
|
|
clearImmediate: false,
|
|
setImmediate: false
|
|
}
|
|
|
|
});
|
|
}
|