node.js - ReferenceError: webpack is not defined -
in webpack app have basic build process that's triggered "npm run build" executes webpack binary , copies index.html in /app /dist. whenever run npm run build
referenceerror: webpack not defined
when run npm start
, starts webpack-dev-server, everything's fine.
this webpack config file:
var extracttextplugin = require('extract-text-webpack-plugin'); var config = { context: __dirname + '/app', entry: './index.js', output: { path: __dirname + '/app', filename: 'app.js' }, module: { loaders: [ { test: /\.js$/, loader: 'babel', exclude: /node_modules/ }, { test: /\.html$/, loader: 'raw', exclude: /node_modules/ }, { test: /\.scss$/, loader: extracttextplugin.extract('style', 'css!sass'), exclude: /node_modules/} ] }, plugins: [ new extracttextplugin('app.css') ] }; if (process.env.node_env == 'production') { config.output.path = __dirname + '/dist'; config.plugins.push(new webpack.optimize.uglifyjsplugin()); } module.exports = config;
you missing
var webpack = require('webpack');
at beginning of file. if want optimize execution bit, can push inside if
block of yours.
Comments
Post a Comment