node.js - WebPack-Dev-Server error: require is not defined -
webpack working fine, webpack-dev-server not. basically, webpack created 2 build files me, back-end bundle , front-end bundle. so, have webpack-config.js each of these. want develop front-end code webpack-dev-server, can see webpack-config file front-end-bundle.js below. when run web-pack-dev server, able find , build front-end.js , index.html, nothing renders in console , gives me "uncaught referenceerror: require not defined"
// var nodeexternals = require('webpack-node-externals'); var webpack = require('webpack'); module.exports = { entry: './browser/entry.js', output: { path: './builds', filename: 'frontend.js' }, plugins: [ new webpack.defineplugin({ 'process.env.node_env': '"development"' }), new webpack.defineplugin({ 'process.env': { 'node_env': '"development"' } }) ], module: { loaders: [ { test: [/\.es6$/, /\.js$/, /\.jsx$/], exclude: 'node_modules', loader: 'babel-loader', query: { presets: ['react', 'es2015', 'stage-1'] } }, { test: /\.json$/, loader: 'json-loader' }, { test: /\.html$/, loader: 'html-loader' }, ] }, resolve: { extensions: ['', '.js', '.es6', '.json'], root: '/users/johnhenry/desktop/gamr/gamr/browser' }, devserver: { contentbase: 'builds/dev-build' }, target: 'node', // externals: [nodeexternals()] }
the error triggered in front-end build (it in dev server build, not in non-dev-server webpack build):
function(module, exports) { module.exports = require("url");
if has insight this, appreciated
try adding:
target: 'web'
to module block.
Comments
Post a Comment