In meiner Webpack-App habe ich einen grundlegenden Build-Prozess, der von "npm run build" ausgelöst wird, der die Webpack-Binärdatei ausführt und meine index.html in/app nach/dist kopiert. Immer wenn ich npm run build
laufen lasse, erhalte ich ReferenceError: webpack is not defined
, aber wenn ich npm start
laufe, der den webpack-dev-server startet, ist alles in Ordnung.ReferenceError: Webpack ist nicht definiert
Das ist meine webpack Konfigurationsdatei:
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;
Ich musste auch laufen: 'npm install --save webpack' –