plugins
é项ç¨äºä»¥åç§æ¹å¼èªå®ä¹ webpack æ建è¿ç¨ãwebpack é带äºåç§å
ç½®æ件ï¼å¯ä»¥éè¿ webpack.[plugin-name]
访é®è¿äºæ件ã请æ¥ç æä»¶é¡µé¢ è·åæ件å表å对åºææ¡£ï¼ä½è¯·æ³¨æè¿åªæ¯å
¶ä¸ä¸é¨åï¼ç¤¾åºä¸è¿æ许å¤æ件ã
ä¸ç» webpack æ件ãä¾å¦ï¼DefinePlugin
å
è®¸ä½ å建å¯å¨ç¼è¯æ¶é
ç½®çå
¨å±å¸¸éãè¿å¯¹éè¦åå¼åç¯å¢æ建åç产ç¯å¢æ建ä¹é´äº§çä¸åè¡ä¸ºæ¥è¯´é常æç¨ã
webpack.config.js
module.exports = {
//...
plugins: [
new webpack.DefinePlugin({
// Definitions...
}),
],
};
ä¸ä¸ªå¤æ示ä¾ï¼ä½¿ç¨å¤ä¸ªæ件ï¼å¯è½çèµ·æ¥å°±åè¿æ ·ï¼
webpack.config.js
var webpack = require('webpack');
// 导å
¥é webpack èªå¸¦é»è®¤æ件
var DashboardPlugin = require('webpack-dashboard/plugin');
// å¨é
ç½®ä¸æ·»å æ件
module.exports = {
//...
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// ç¼è¯æ¶(compile time)æ件
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
// webpack-dev-server 强åæ件
new DashboardPlugin(),
new webpack.HotModuleReplacementPlugin(),
],
};