Skip to content

TagSpaces is an offline, open source, document manager with tagging support

boilerplace integration

Ilian Sapundshiev0d94c33d69e2
diff --git a/app/appd.html b/app/appd.html
index aba5cc602..86a9ace9d 100644
--- a/app/appd.html
+++ b/app/appd.html
@@ -2,11 +2,17 @@
<html>
<head>
<title>TagSpaces Desktop Dev</title>
- <meta http-equiv="Content-Security-Policy" content="connect-src file: *; default-src 'self' ; font-src http://localhost:1212 'self'; script-src http://localhost:1212 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' data: blob: ; media-src *; img-src * data: content:;">
- <meta charset="utf-8">
- <meta name="format-detection" content="telephone=no">
- <meta name="msapplication-tap-highlight" content="no">
- <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
+ <meta
+ http-equiv="Content-Security-Policy"
+ content="connect-src file: *; default-src 'self' ; font-src http://localhost:1212 'self'; script-src http://localhost:1212 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' data: blob: ; media-src *; img-src * data: content:;"
+ />
+ <meta charset="utf-8" />
+ <meta name="format-detection" content="telephone=no" />
+ <meta name="msapplication-tap-highlight" content="no" />
+ <meta
+ name="viewport"
+ content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"
+ />
<!-- script type="text/javascript" src="./node_modules/@tagspaces/pro/extconfig.template.js"></script-->
<script type="text/javascript" src="./extconfig.js"></script>
<script type="text/javascript">
@@ -20,7 +26,7 @@
if (process.env.NODE_ENV === 'development') {
const script = document.createElement('script');
- script.src = '../dll/vendor.dll.js';
+ script.src = '../dll/renderer.dev.dll.js';
script.type = 'text/javascript';
script.defer = true;
document.getElementsByTagName('head')[0].appendChild(script);
@@ -28,32 +34,83 @@
const port = process.env.PORT || 1212;
const bundleScript = document.createElement('script');
- bundleScript.src = (process.env.HOT) ? 'http://localhost:' + port + '/dist/bundle.js' : './dist/bundle.js';
+ bundleScript.src = process.env.HOT
+ ? 'http://localhost:' + port + '/dist/bundle.js'
+ : './dist/bundle.js';
bundleScript.type = 'text/javascript';
bundleScript.defer = true;
document.getElementsByTagName('head')[0].appendChild(bundleScript);
}
</script>
</head>
- <body style="overflow: hidden; margin: 0; padding: 0; background-color: rgb(88, 88, 88);">
+ <body
+ style="overflow: hidden; margin: 0; padding: 0; background-color: rgb(88, 88, 88);"
+ >
<div id="root">
- <div style="text-align: center; width: 100%; height: 100%; font-size: 1.4em; position:absolute; z-index: 999999; user-select: none; -webkit-user-select: none; -moz-user-select: none; -webkit-app-region: drag" class="appBackgroundTile">
- <div style="top:45%; width: 100%; text-align: center; position:absolute;">
- <svg style="vertical-align: middle" xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100">
- <g id="layer1" transform="matrix(0.33346217,0,0,0.33346217,-0.01300084,-250.91)">
- <rect style="fill:none;fill-opacity:1;stroke:none" id="rect3052-8-1" width="299.42227" height="299.42227" x="-0.019505024" y="752.95935" />
- <path style="fill:#ffffff;fill-opacity:1;stroke:none" d="m 181.90177,787.75394 70.88695,43.53834 C 180.29225,977.67059 187.41436,950.59754 124.58989,989.154 L 65.05006,905.90077 Z" id="rect3052-8-2-2" />
- <ellipse style="fill:#616577;fill-opacity:1;stroke:none" id="path4875-4-7-5-6-2" cx="192.4187" cy="851.11481" rx="15.970615" ry="15.782593" />
- <path style="fill:none;stroke:#a466aa;stroke-width:27.50978279;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 159.73623,964.91671 134.54529,941.61879" id="path3108-5-39-8" />
- <path style="fill:none;stroke:#ffffff;stroke-width:34.19813538;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 162.16161,795.17204 90.03628,0.34544 0,86.1724 -115.50748,117.79375 -88.457192,-81.6665 z" id="path3923-1-1-4-9-8" />
- <path style="fill:#f7901e;fill-opacity:1;stroke:#33b5be;stroke-width:27.50978279;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 204.81469,910.87834 -50.38182,-45.3016" id="path3108-9-1-76-7" />
- <path style="fill:#616577;fill-opacity:1;stroke:#f7901e;stroke-width:27.50978279;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 182.93838,938.7066 144.48907,904.40668" id="path3108-0-7-9-8" />
- <path style="fill:none;stroke:#616577;stroke-width:31.96374702;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 164.34385,800.70161 83.03644,0 0,79.10209 -110.49206,113.42316 -82.031957,-75.83333 z" id="path3923-1-1-4-9" />
+ <div
+ style="text-align: center; width: 100%; height: 100%; font-size: 1.4em; position:absolute; z-index: 999999; user-select: none; -webkit-user-select: none; -moz-user-select: none; -webkit-app-region: drag"
+ class="appBackgroundTile"
+ >
+ <div
+ style="top:45%; width: 100%; text-align: center; position:absolute;"
+ >
+ <svg
+ style="vertical-align: middle"
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.1"
+ width="100"
+ height="100"
+ >
+ <g
+ id="layer1"
+ transform="matrix(0.33346217,0,0,0.33346217,-0.01300084,-250.91)"
+ >
+ <rect
+ style="fill:none;fill-opacity:1;stroke:none"
+ id="rect3052-8-1"
+ width="299.42227"
+ height="299.42227"
+ x="-0.019505024"
+ y="752.95935"
+ />
+ <path
+ style="fill:#ffffff;fill-opacity:1;stroke:none"
+ d="m 181.90177,787.75394 70.88695,43.53834 C 180.29225,977.67059 187.41436,950.59754 124.58989,989.154 L 65.05006,905.90077 Z"
+ id="rect3052-8-2-2"
+ />
+ <ellipse
+ style="fill:#616577;fill-opacity:1;stroke:none"
+ id="path4875-4-7-5-6-2"
+ cx="192.4187"
+ cy="851.11481"
+ rx="15.970615"
+ ry="15.782593"
+ />
+ <path
+ style="fill:none;stroke:#a466aa;stroke-width:27.50978279;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 159.73623,964.91671 134.54529,941.61879"
+ id="path3108-5-39-8"
+ />
+ <path
+ style="fill:none;stroke:#ffffff;stroke-width:34.19813538;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 162.16161,795.17204 90.03628,0.34544 0,86.1724 -115.50748,117.79375 -88.457192,-81.6665 z"
+ id="path3923-1-1-4-9-8"
+ />
+ <path
+ style="fill:#f7901e;fill-opacity:1;stroke:#33b5be;stroke-width:27.50978279;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 204.81469,910.87834 -50.38182,-45.3016"
+ id="path3108-9-1-76-7"
+ />
+ <path
+ style="fill:#616577;fill-opacity:1;stroke:#f7901e;stroke-width:27.50978279;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 182.93838,938.7066 144.48907,904.40668"
+ id="path3108-0-7-9-8"
+ />
+ <path
+ style="fill:none;stroke:#616577;stroke-width:31.96374702;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 164.34385,800.70161 83.03644,0 0,79.10209 -110.49206,113.42316 -82.031957,-75.83333 z"
+ id="path3923-1-1-4-9"
+ />
</g>
</svg>
</div>
diff --git a/app/main.dev.babel.js b/app/main.dev.babel.js
new file mode 100644
index 000000000..31dd89107
--- /dev/null
+++ b/app/main.dev.babel.js
@@ -0,0 +1,7 @@
+const register = require('@babel/register').default;
+
+register({
+ extensions: ['.ts', '.tsx', '.js', '.json']
+});
+
+require('./main.dev.ts');
diff --git a/configs/webpack.config.base.js b/configs/webpack.config.base.js
new file mode 100644
index 000000000..17e76c5cf
--- /dev/null
+++ b/configs/webpack.config.base.js
@@ -0,0 +1,50 @@
+/**
+ * Base webpack config used across other specific configs
+ */
+
+import path from 'path';
+import webpack from 'webpack';
+import { dependencies } from '../package.json';
+
+export default {
+ externals: [...Object.keys(dependencies || {})],
+
+ module: {
+ rules: [
+ {
+ test: /\.[jt]sx?$/,
+ exclude: /node_modules/,
+ use: [
+ {
+ loader: 'babel-loader',
+ options: {
+ cacheDirectory: true
+ }
+ },
+ 'ts-loader'
+ ]
+ }
+ ]
+ },
+
+ output: {
+ path: path.join(__dirname, '..', 'app'),
+ // https://github.com/webpack/webpack/issues/1114
+ libraryTarget: 'commonjs2'
+ },
+
+ /**
+ * Determine the array of extensions that should be used to resolve modules.
+ */
+ resolve: {
+ extensions: ['.js', '.ts', '.tsx', '.json']
+ },
+
+ plugins: [
+ new webpack.EnvironmentPlugin({
+ NODE_ENV: 'production'
+ }),
+
+ new webpack.NamedModulesPlugin()
+ ]
+};
diff --git a/configs/webpack.config.eslint.js b/configs/webpack.config.eslint.js
new file mode 100644
index 000000000..bd000487d
--- /dev/null
+++ b/configs/webpack.config.eslint.js
@@ -0,0 +1,4 @@
+/* eslint import/no-unresolved: off, import/no-self-import: off */
+require('@babel/register');
+
+module.exports = require('./webpack.config.renderer.dev.babel').default;
diff --git a/configs/webpack.config.main.prod.babel.js b/configs/webpack.config.main.prod.babel.js
new file mode 100644
index 000000000..058f02f1c
--- /dev/null
+++ b/configs/webpack.config.main.prod.babel.js
@@ -0,0 +1,73 @@
+/**
+ * Webpack config for production electron main process
+ */
+
+import path from 'path';
+import webpack from 'webpack';
+import merge from 'webpack-merge';
+import TerserPlugin from 'terser-webpack-plugin';
+import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
+import baseConfig from './webpack.config.base';
+import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+
+CheckNodeEnv('production');
+
+export default merge.smart(baseConfig, {
+ devtool: 'source-map',
+
+ mode: 'production',
+
+ target: 'electron-main',
+
+ entry: './app/main.dev',
+
+ output: {
+ path: path.join(__dirname, '..'),
+ filename: './app/main.prod.js'
+ },
+
+ optimization: {
+ minimizer: process.env.E2E_BUILD
+ ? []
+ : [
+ new TerserPlugin({
+ parallel: true,
+ sourceMap: true,
+ cache: true
+ })
+ ]
+ },
+
+ plugins: [
+ new BundleAnalyzerPlugin({
+ analyzerMode:
+ process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
+ openAnalyzer: process.env.OPEN_ANALYZER === 'true'
+ }),
+
+ /**
+ * Create global constants which can be configured at compile time.
+ *
+ * Useful for allowing different behaviour between development builds and
+ * release builds
+ *
+ * NODE_ENV should be production so that modules do not perform certain
+ * development checks
+ */
+ new webpack.EnvironmentPlugin({
+ NODE_ENV: 'production',
+ DEBUG_PROD: false,
+ START_MINIMIZED: false
+ })
+ ],
+
+ /**
+ * Disables webpack processing of __dirname and __filename.
+ * If you run the bundle in node.js it falls back to these values of node.js.
+ * https://github.com/webpack/webpack/issues/2010
+ */
+ node: {
+ __dirname: false,
+ __filename: false
+ }
+});
diff --git a/configs/webpack.config.renderer.dev.babel.js b/configs/webpack.config.renderer.dev.babel.js
new file mode 100644
index 000000000..961ca6110
--- /dev/null
+++ b/configs/webpack.config.renderer.dev.babel.js
@@ -0,0 +1,268 @@
+/* eslint global-require: off, import/no-dynamic-require: off */
+
+/**
+ * Build config for development electron renderer process that uses
+ * Hot-Module-Replacement
+ *
+ * https://webpack.js.org/concepts/hot-module-replacement/
+ */
+
+import path from 'path';
+import fs from 'fs';
+import webpack from 'webpack';
+import chalk from 'chalk';
+import merge from 'webpack-merge';
+import { spawn, execSync } from 'child_process';
+import baseConfig from './webpack.config.base';
+import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+
+CheckNodeEnv('development');
+
+const port = process.env.PORT || 1212;
+const publicPath = `http://localhost:${port}/dist`;
+const dll = path.join(__dirname, '..', 'dll');
+const manifest = path.resolve(dll, 'renderer.json');
+const requiredByDLLConfig = module.parent.filename.includes(
+ 'webpack.config.renderer.dev.dll'
+);
+
+/**
+ * Warn if the DLL is not built
+ */
+if (!requiredByDLLConfig && !(fs.existsSync(dll) && fs.existsSync(manifest))) {
+ console.log(
+ chalk.black.bgYellow.bold(
+ 'The DLL files are missing. Sit back while we build them for you with "yarn build-dll"'
+ )
+ );
+ execSync('yarn build-dll');
+}
+
+export default merge.smart(baseConfig, {
+ devtool: 'inline-source-map',
+
+ mode: 'development',
+
+ target: 'electron-renderer',
+
+ entry: [
+ 'react-hot-loader/patch',
+ `webpack-dev-server/client?http://localhost:${port}/`,
+ 'webpack/hot/only-dev-server',
+ require.resolve('../app/index.tsx')
+ ],
+
+ output: {
+ publicPath: `http://localhost:${port}/dist/`,
+ filename: 'renderer.dev.js'
+ },
+
+ module: {
+ rules: [
+ {
+ test: /\.global\.css$/,
+ use: [
+ {
+ loader: 'style-loader'
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ sourceMap: true
+ }
+ }
+ ]
+ },
+ {
+ test: /^((?!\.global).)*\.css$/,
+ use: [
+ {
+ loader: 'style-loader'
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ modules: true,
+ sourceMap: true,
+ importLoaders: 1,
+ localIdentName: '[name]__[local]__[hash:base64:5]'
+ }
+ }
+ ]
+ },
+ // SASS support - compile all .global.scss files and pipe it to style.css
+ {
+ test: /\.global\.(scss|sass)$/,
+ use: [
+ {
+ loader: 'style-loader'
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ sourceMap: true
+ }
+ },
+ {
+ loader: 'sass-loader'
+ }
+ ]
+ },
+ // SASS support - compile all other .scss files and pipe it to style.css
+ {
+ test: /^((?!\.global).)*\.(scss|sass)$/,
+ use: [
+ {
+ loader: 'style-loader'
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ modules: true,
+ sourceMap: true,
+ importLoaders: 1,
+ localIdentName: '[name]__[local]__[hash:base64:5]'
+ }
+ },
+ {
+ loader: 'sass-loader'
+ }
+ ]
+ },
+ // WOFF Font
+ {
+ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'application/font-woff'
+ }
+ }
+ },
+ // WOFF2 Font
+ {
+ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'application/font-woff'
+ }
+ }
+ },
+ // TTF Font
+ {
+ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'application/octet-stream'
+ }
+ }
+ },
+ // EOT Font
+ {
+ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
+ use: 'file-loader'
+ },
+ // SVG Font
+ {
+ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'image/svg+xml'
+ }
+ }
+ },
+ // Text files
+ {
+ test: /\.(txt)$/,
+ use: 'raw-loader'
+ },
+ // Common Image Formats
+ {
+ test: /\.(?:ico|gif|png|jpg|jpeg|webp|svg)$/,
+ use: 'url-loader'
+ }
+ ]
+ },
+
+ plugins: [
+ requiredByDLLConfig
+ ? null
+ : new webpack.DllReferencePlugin({
+ context: path.join(__dirname, '..', 'dll'),
+ manifest: require(manifest),
+ sourceType: 'var'
+ }),
+
+ new webpack.HotModuleReplacementPlugin({
+ multiStep: true
+ }),
+
+ new webpack.NoEmitOnErrorsPlugin(),
+
+ /**
+ * Create global constants which can be configured at compile time.
+ *
+ * Useful for allowing different behaviour between development builds and
+ * release builds
+ *
+ * NODE_ENV should be production so that modules do not perform certain
+ * development checks
+ *
+ * By default, use 'development' as NODE_ENV. This can be overriden with
+ * 'staging', for example, by changing the ENV variables in the npm scripts
+ */
+ new webpack.EnvironmentPlugin({
+ NODE_ENV: 'development'
+ }),
+
+ new webpack.LoaderOptionsPlugin({
+ debug: true
+ })
+ ],
+
+ node: {
+ __dirname: false,
+ __filename: false
+ },
+
+ devServer: {
+ port,
+ publicPath,
+ compress: true,
+ noInfo: true,
+ stats: 'errors-only',
+ inline: true,
+ lazy: false,
+ hot: true,
+ headers: { 'Access-Control-Allow-Origin': '*' },
+ contentBase: path.join(__dirname, 'dist'),
+ watchOptions: {
+ aggregateTimeout: 300,
+ ignored: /node_modules/,
+ poll: 100
+ },
+ historyApiFallback: {
+ verbose: true,
+ disableDotRule: false
+ },
+ before() {
+ if (process.env.START_HOT) {
+ console.log('Starting Main Process...');
+ spawn('npm', ['run', 'start-main-dev'], {
+ shell: true,
+ env: process.env,
+ stdio: 'inherit'
+ })
+ .on('close', code => process.exit(code))
+ .on('error', spawnError => console.error(spawnError));
+ }
+ }
+ }
+});
diff --git a/configs/webpack.config.renderer.dev.dll.babel.js b/configs/webpack.config.renderer.dev.dll.babel.js
new file mode 100644
index 000000000..f80e40fa0
--- /dev/null
+++ b/configs/webpack.config.renderer.dev.dll.babel.js
@@ -0,0 +1,74 @@
+/* eslint global-require: off, import/no-dynamic-require: off */
+
+/**
+ * Builds the DLL for development electron renderer process
+ */
+
+import webpack from 'webpack';
+import path from 'path';
+import merge from 'webpack-merge';
+import baseConfig from './webpack.config.base';
+import { dependencies } from '../package.json';
+import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+
+CheckNodeEnv('development');
+
+const dist = path.join(__dirname, '..', 'dll');
+
+export default merge.smart(baseConfig, {
+ context: path.join(__dirname, '..'),
+
+ devtool: 'eval',
+
+ mode: 'development',
+
+ target: 'electron-renderer',
+
+ externals: ['fsevents', 'crypto-browserify'],
+
+ /**
+ * Use `module` from `webpack.config.renderer.dev.js`
+ */
+ module: require('./webpack.config.renderer.dev.babel').default.module,
+
+ entry: {
+ renderer: Object.keys(dependencies || {})
+ },
+
+ output: {
+ library: 'renderer',
+ path: dist,
+ filename: '[name].dev.dll.js',
+ libraryTarget: 'var'
+ },
+
+ plugins: [
+ new webpack.DllPlugin({
+ path: path.join(dist, '[name].json'),
+ name: '[name]'
+ }),
+
+ /**
+ * Create global constants which can be configured at compile time.
+ *
+ * Useful for allowing different behaviour between development builds and
+ * release builds
+ *
+ * NODE_ENV should be production so that modules do not perform certain
+ * development checks
+ */
+ new webpack.EnvironmentPlugin({
+ NODE_ENV: 'development'
+ }),
+
+ new webpack.LoaderOptionsPlugin({
+ debug: true,
+ options: {
+ context: path.join(__dirname, '..', 'app'),
+ output: {
+ path: path.join(__dirname, '..', 'dll')
+ }
+ }
+ })
+ ]
+});
diff --git a/configs/webpack.config.renderer.prod.babel.js b/configs/webpack.config.renderer.prod.babel.js
new file mode 100644
index 000000000..2bdadffe8
--- /dev/null
+++ b/configs/webpack.config.renderer.prod.babel.js
@@ -0,0 +1,220 @@
+/**
+ * Build config for electron renderer process
+ */
+
+import path from 'path';
+import webpack from 'webpack';
+import MiniCssExtractPlugin from 'mini-css-extract-plugin';
+import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
+import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
+import merge from 'webpack-merge';
+import TerserPlugin from 'terser-webpack-plugin';
+import baseConfig from './webpack.config.base';
+import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+
+CheckNodeEnv('production');
+export default merge.smart(baseConfig, {
+ devtool: 'source-map',
+
+ mode: 'production',
+
+ target: 'electron-renderer',
+
+ entry: path.join(__dirname, '..', 'app/index'),
+
+ output: {
+ path: path.join(__dirname, '..', 'app/dist'),
+ publicPath: './dist/',
+ filename: 'renderer.prod.js'
+ },
+
+ module: {
+ rules: [
+ // Extract all .global.css to style.css as is
+ {
+ test: /\.global\.css$/,
+ use: [
+ {
+ loader: MiniCssExtractPlugin.loader,
+ options: {
+ publicPath: './'
+ }
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ sourceMap: true
+ }
+ }
+ ]
+ },
+ // Pipe other styles through css modules and append to style.css
+ {
+ test: /^((?!\.global).)*\.css$/,
+ use: [
+ {
+ loader: MiniCssExtractPlugin.loader
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ modules: true,
+ localIdentName: '[name]__[local]__[hash:base64:5]',
+ sourceMap: true
+ }
+ }
+ ]
+ },
+ // Add SASS support - compile all .global.scss files and pipe it to style.css
+ {
+ test: /\.global\.(scss|sass)$/,
+ use: [
+ {
+ loader: MiniCssExtractPlugin.loader
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ sourceMap: true,
+ importLoaders: 1
+ }
+ },
+ {
+ loader: 'sass-loader',
+ options: {
+ sourceMap: true
+ }
+ }
+ ]
+ },
+ // Add SASS support - compile all other .scss files and pipe it to style.css
+ {
+ test: /^((?!\.global).)*\.(scss|sass)$/,
+ use: [
+ {
+ loader: MiniCssExtractPlugin.loader
+ },
+ {
+ loader: 'css-loader',
+ options: {
+ modules: true,
+ importLoaders: 1,
+ localIdentName: '[name]__[local]__[hash:base64:5]',
+ sourceMap: true
+ }
+ },
+ {
+ loader: 'sass-loader',
+ options: {
+ sourceMap: true
+ }
+ }
+ ]
+ },
+ // WOFF Font
+ {
+ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'application/font-woff'
+ }
+ }
+ },
+ // WOFF2 Font
+ {
+ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'application/font-woff'
+ }
+ }
+ },
+ // TTF Font
+ {
+ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'application/octet-stream'
+ }
+ }
+ },
+ // EOT Font
+ {
+ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
+ use: 'file-loader'
+ },
+ // SVG Font
+ {
+ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
+ use: {
+ loader: 'url-loader',
+ options: {
+ limit: 10000,
+ mimetype: 'image/svg+xml'
+ }
+ }
+ },
+ // Text files
+ {
+ test: /\.(txt)$/,
+ use: 'raw-loader'
+ },
+ // Common Image Formats
+ {
+ test: /\.(?:ico|gif|png|jpg|jpeg|webp|svg)$/,
+ use: 'url-loader'
+ }
+ ]
+ },
+
+ optimization: {
+ minimizer: process.env.E2E_BUILD
+ ? []
+ : [
+ new TerserPlugin({
+ parallel: true,
+ sourceMap: true,
+ cache: true
+ }),
+ new OptimizeCSSAssetsPlugin({
+ cssProcessorOptions: {
+ map: {
+ inline: false,
+ annotation: true
+ }
+ }
+ })
+ ]
+ },
+
+ plugins: [
+ /**
+ * Create global constants which can be configured at compile time.
+ *
+ * Useful for allowing different behaviour between development builds and
+ * release builds
+ *
+ * NODE_ENV should be production so that modules do not perform certain
+ * development checks
+ */
+ new webpack.EnvironmentPlugin({
+ NODE_ENV: 'production'
+ }),
+
+ new MiniCssExtractPlugin({
+ filename: 'style.css'
+ }),
+
+ new BundleAnalyzerPlugin({
+ analyzerMode:
+ process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
+ openAnalyzer: process.env.OPEN_ANALYZER === 'true'
+ })
+ ]
+});