Skip to content
Snippets Groups Projects
Select Git revision
  • 81bc116c4db70ddda1d2297c87fde9f7eed2d2c2
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

webpack.config.common.js

Blame
  • webpack.config.common.js 3.78 KiB
    const path = require('path');
    const webpack = require('webpack');
    const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
    const MiniCssExtractPlugin = require('mini-css-extract-plugin');
    const VersionFile = require('webpack-version-file-plugin');
    
    const sharedConfig = {
        module: {
            rules: [
                {
                    test: /\.(html|ico)$/,
                    use: [{
                        loader: 'file-loader',
                        options: { name: '[name].[ext]' }
                    }]
                },
                {
                    test: /\.(s*)css$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        { loader: 'css-loader', options: { sourceMap: false } },
                        { loader: 'sass-loader', options: { sourceMap: false } },
                    ]
                }
            ]
        },
        plugins: [
            new ExtraWatchWebpackPlugin({
                files: [
                    './lib/**/*.scss',
                    './lib/**/*.html'
                ],
            }),
            new webpack.DefinePlugin({
                'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
                '__MOLSTAR_DEBUG_TIMESTAMP__': webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true)
            }),
            new MiniCssExtractPlugin({ filename: 'molstar.css',  }),
            new VersionFile({
                extras: { timestamp: `${new Date().valueOf()}` },
                packageFile: path.resolve(__dirname, 'package.json'),
                templateString: `export var PLUGIN_VERSION = '<%= package.version %>';\nexport var PLUGIN_VERSION_DATE = new Date(typeof __MOLSTAR_DEBUG_TIMESTAMP__ !== 'undefined' ? __MOLSTAR_DEBUG_TIMESTAMP__ : <%= extras.timestamp %>);`,
                outputFile: path.resolve(__dirname, 'lib/mol-plugin/version.js')
            })
        ],
        resolve: {
            modules: [
                'node_modules',
                path.resolve(__dirname, 'lib/')
            ],
        },
        watchOptions: {
            aggregateTimeout: 750
        },
        devtool: ''
    };
    
    function createEntry(src, outFolder, outFilename, isNode) {
        return {
            node: isNode ? void 0 : { fs: 'empty' }, // TODO find better solution? Currently used in file-handle.ts
            target: isNode ? 'node' : void 0,
            entry: path.resolve(__dirname, `lib/${src}.js`),
            output: { filename: `${outFilename}.js`, path: path.resolve(__dirname, `build/${outFolder}`) },
            ...sharedConfig
        };
    }
    
    function createEntryPoint(name, dir, out, library) {
        return {
            node: { fs: 'empty' }, // TODO find better solution? Currently used in file-handle.ts