I've got an error('ReferenceError: require is not defined')
in the following syntax, and I using '@babel/preset-env' now.
How do I solve this problem?
const _ = require("lodash.template");
(I am trying to use the lodash library in the es6 development environment.)
package.json
"@babel/preset-env": "^7.0.0"
webpack.config.js
presets: ['@babel/preset-env']
The entire Webpack config looks like this:
const webpack = require('webpack');
const path = require('path');
module.exports = {
    entry: './src/js/App.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/dist/',
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                include: path.join(__dirname),
                exclude: /(node_modules)|(dist)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            }
        ]
    }
};
some context of of the usage:
let litemplate  =`<li class="id">[<%=data[i].id%>]</li>`;
let listemplate = _.template(litemplate);
 
    