发布网友 发布时间:2022-04-23 17:45
共3个回答
热心网友 时间:2022-05-12 01:47
1.准备:热心网友 时间:2022-05-12 03:05
1.准备:热心网友 时间:2022-05-12 04:40
这种配置方式和你的可能有点不同,仅作参考dev.config.js部分varpath=require('path');varwebpack=require('webpack');varExtractTextPlugin=require('extract-text-webpack-plugin');varautoprefixer=require('autoprefixer');varcsswring=require('csswring');mole.exports={devtool:'cheap-mole-eval-source-map',entry:['webpack-hot-middleware/client','./src/index',],output:{filename:'bundle.js',path:path.join(__dirname,'/dist/'),publicPath:'/dist/',},plugins:[newwebpack.DefinePlugin({__DEVELOPMENT__:true}),newExtractTextPlugin('bundle.css'),newwebpack.optimize.OccurenceOrderPlugin(),newwebpack.HotMoleReplacementPlugin(),newwebpack.NoErrorsPlugin(),newwebpack.ProvidePlugin({jQuery:'jquery',}),],resolve:{extensions:['','.jsx','.js','.json'],molesDirectories:['node_moles','src'],},mole:{loaders:[{test:/bootstrap\/js\//,loader:'imports?jQuery=jquery',},{test:/\.woff(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/font-woff',},{test:/\.woff2(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/font-woff2',},{test:/\.ttf(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/octet-stream',},{test:/\.otf(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/font-otf',},{test:/\.eot(\?v=\d+\.\d+\.\d+)?$/,loader:'file',},{test:/\.svg(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=image/svg+xml',},{test:/\.js$/,loaders:['react-hot','babel?stage=0&loose[]=es6.moles'],exclude:/node_moles/,},{test:/\.scss$/,loader:'css?localIdentName=[path]!postcss-loader!sass',},{test:/\.png$/,loader:'file?name=[name].[ext]',},{test:/\.jpg$/,loader:'file?name=[name].[ext]',}],},postcss:function(){return[autoprefixer({browsers:['last2versions','safari5','ie9','ios6','android4']}),csswring];},};prod.config,js部分varpath=require('path');varwebpack=require('webpack');varExtractTextPlugin=require('extract-text-webpack-plugin');varautoprefixer=require('autoprefixer');varcsswring=require('csswring');mole.exports={devtool:'source-map',entry:['./src/index',],output:{filename:'bundle.js',path:path.join(__dirname,'../dist/'),publicPath:'dist/',},plugins:[newwebpack.DefinePlugin({'process.env':{NODE_ENV:'"proction"',},__DEVELOPMENT__:false,}),newExtractTextPlugin('bundle.css'),newwebpack.optimize.DepePlugin(),newwebpack.optimize.OccurenceOrderPlugin(),newwebpack.optimize.UglifyJsPlugin({compress:{warnings:false,},}),newwebpack.ProvidePlugin({jQuery:'jquery',}),],resolve:{extensions:['','.jsx','.js','.json'],molesDirectories:['node_moles','src'],},mole:{loaders:[{test:/bootstrap\/js\//,loader:'imports?jQuery=jquery',},{test:/\.woff(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/font-woff',},{test:/\.woff2(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/font-woff2',},{test:/\.ttf(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/octet-stream',},{test:/\.otf(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=application/font-otf',},{test:/\.eot(\?v=\d+\.\d+\.\d+)?$/,loader:'file',},{test:/\.svg(\?v=\d+\.\d+\.\d+)?$/,loader:'url?limit=10000&mimetype=image/svg+xml',},{test:/\.js$/,loaders:['react-hot','babel?stage=0&loose[]=es6.moles'],exclude:/node_moles/,},{test:/\.scss$/,loader:'css!postcss-loader!sass',},{test:/\.png$/,loader:'file?name=[name].[ext]',},{test:/\.jpg$/,loader:'file?name=[name].[ext]',}],},postcss:function(){return[autoprefixer({browsers:['last2versions','safari5','ie9','ios6','android4']}),csswring];},};