Skip to content

Unable to use math.js on frontend with webpack #601

@chmln

Description

@chmln

Hello!

First off, koodos to author for a fantastic library.

I'm having trouble importing mathjs to frontend through webpack.

Whenever I import mathjs, here's what happens:
webpack

The module is imported like any other node module.
code

And here's my webpack config

var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: ['./src/main.js'],
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/',
    filename: 'build.js'
  },
  resolveLoader: {
    root: path.join(__dirname, 'node_modules'),
  },
  module: {
    loaders: [

        { test: /\.jade$/, loader: "jade" },

        { 
            test: /\.js$/, 
            loader: 'babel', 
            include: [                
                path.resolve(__dirname, "src")
              ] 
        },

        { test: /\.json$/, loader: 'json' },

        { test: /\.vue$/, loader: 'vue' },

        { test: /\.scss$/, loaders: ["style", "css", "sass"], exclude: /node_modules/ },

        { 
            test: /\.styl$/,
            loaders: ["style", "css", "stylus"],
            exclude: /node_modules/

        },

        {
            test: /\.(png|jpg|gif|svg)$/,
            loader: 'url',
            query: {
            limit: 10000,
            name: '[name].[ext]?[hash]'
        }

      }
    ]
  },

  devtool: 'eval-source-map'
}

module.exports.devtool = 'source-map'
// http://vuejs.github.io/vue-loader/workflow/production.html

module.exports.plugins = (module.exports.plugins || []).concat([

    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),

    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),

    new webpack.optimize.OccurenceOrderPlugin()

])

No problems, however, using mathjs in node backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions