mathjax / MathJax-demos-web

A repository with examples using mathjax-v3
https://mathjax.github.io/MathJax-demos-web
Apache License 2.0
256 stars 106 forks source link

a note on using the alpha.1 copy on npm #3

Closed pkra closed 5 years ago

pkra commented 6 years ago

The first alpha on npm has a drawback when it comes to the harcoded fonts. They end up in node_modules/mathjax3/mathjax2/css/... so if you build something you need to copy these along.

Of course that's not hard -- the copy-webpack-plugin is your friend, e.g.,

// $ npm install mathjax3 webpack copy-webpack-plugin babel-core babel-preset-env babel-loader uglifyjs-webpack-plugin

const Uglify = require("uglifyjs-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');

module.exports = {
    name: 'yourscript',
    entry: './yourscript.js',
    output: {
        path: __dirname,
        filename: 'yourscript.dist.js'
    },
    module: {
        rules: [{
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            use: {
                loader: 'babel-loader',
                options: {
                    presets: ['env']
                }
            }
        }]
    },
    plugins: [
        new Uglify(),
        new CopyWebpackPlugin([
            { from: 'node_modules/mathjax3/mathjax2', to: './mathjax2' }
        ])
    ]
};