| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /**
- * Webpack common configuration.
- * it:
- * - Define the app entry point (./src) -> Where webpack will start compiling/bundling
- * - Define where assets will be served at by our webserver (static/)
- * - Clean previous build on each build
- * - Generates the index.html file automatically by injecting bundled assets in it (css, js)
- * - Allow to load html files as strings in js code (i.e: import htmlString from './myHtmlFile.html)
- * - Allow to automatically generates the dependencies injection for angularJS components annotated with
- * `'ngInject';` or `@ngInject` in comments. See https://docs.angularjs.org/guide/di
- */
- const fs = require('fs');
- const path = require('path');
- const {CleanWebpackPlugin} = require('clean-webpack-plugin');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- module.exports = {
- entry: {main: './src/main.ts'},
- output: {
- // Path at which output assets will be served
- publicPath: '',
- },
- // Just for build speed improvement
- resolve: {
- extensions: ['.ts', '.js'],
- symlinks: true,
- modules: [
- __dirname,
- path.resolve(path.join(__dirname, './node_modules')),
- path.resolve(path.join(__dirname, './node_modules', 'hslayers-ng')),
- ],
- },
- plugins: [
- // Clean before build
- new CleanWebpackPlugin(),
- new HtmlWebpackPlugin({
- // Path where the file will be generated (appended to output.path)
- filename: 'index.html',
- template: './src/index.html',
- // We manually inject css and js files in our template
- inject: false,
- favicon: './src/images/cropped-favicon-32x32.png',
- }),
- ],
- module: {
- rules: [
- {
- test: /\.ts$/,
- use: [
- {loader: 'ng-annotate-loader'},
- {loader: 'ts-loader', options: {allowTsInNodeModules: true}},
- ],
- exclude: /node_modules\/(?!(hslayers-ng)\/).*/,
- },
- // Automatically generates $inject array for angularJS components annotated with:
- // 'ngInject';
- // or commented with /**@ngInject */
- {
- test: /\.js$/,
- exclude: /node_modules\/(?!(hslayers-ng)\/).*/,
- use: [
- {
- loader: 'babel-loader',
- options: {
- // Babel syntax dynamic import plugin allow babel to correctly parse js files
- // using webpack dynamic import expression (i.e import('angular').then(...))
- plugins: [
- 'angularjs-annotate',
- '@babel/plugin-syntax-dynamic-import',
- ],
- },
- },
- ],
- },
- {
- test: /\.scss$/,
- use: [
- 'style-loader',
- 'css-loader',
- {
- loader: 'sass-loader',
- options: {
- additionalData: fs.existsSync('./src/custom.scss')
- ? `@use "src/custom.scss" as *;`
- : '',
- },
- },
- ],
- },
- // Load data files
- {
- test: /\.geojson$/,
- include: path.resolve(__dirname, 'src/data'),
- use: {
- loader: 'file-loader',
- options: {
- name: '[name].[ext]',
- outputPath: 'data',
- },
- },
- },
- ],
- },
- };
|