npm run dev
来源:3-8 webpack-dev-server
天热就吃哈密瓜
2018-03-13
老师我都按照您说的配置了 那个长指令可以访问 但是用npm的时候不行 我用的win10 gitbash /* * @Author: Blemon * @Date: 2018-03-12 22:40:25 * @Last Modified by: Blemon * @Last Modified time: 2018-03-13 20:49:36 */ var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin'); //环境变量的配置dev/online var WEBPACK_ENV = process.env.WEBPACK_ENV || 'dev'; console.log(WEBPACK_ENV); //获取html-webpack-plugin参数的方法 var getHtmlConfig = function(name){ return { template : './src/view/'+name+'.html', filename : 'view/'+name+'.html', inject : true, hash : true, chunks : ['common',name] }; }; //webpack config var config = { entry: { 'common' : ['./src/page/common/index.js'], 'index' : ['./src/page/index/index.js'], 'login' : ['./src/page/login/index.js'],//对输入就要对应多输出 }, output: { path : './dist', publicPath : '/dist', filename : 'js/[name].js' }, externals : { 'jquery' : 'window.jQuery' }, module : { loaders : [ {test : /\.css$/, loader: ExtractTextPlugin.extract("style-loader","css-loader")}, {test : /\.(gif|png|jpg|woff|svg|eot|ttf)\??.*$/, loader : 'url-loader?limit=100&name=resource/[name].[ext]'} ] }, plugins : [ //独立通用模块到js/base.js new webpack.optimize.CommonsChunkPlugin({ name : 'common', filename : 'js/base.js' }), //把css单独打包到文件里 new ExtractTextPlugin("css/[name].css"), //html模板的处理 new HtmlWebpackPlugin(getHtmlConfig('index')), new HtmlWebpackPlugin(getHtmlConfig('login')), ] }; if('dev' == WEBPACK_ENV){ config.entry.common.push('webpack-dev-server/client?http://localhost:8088/'); } module.exports = config;
{
"name": "mmall_fe",
"version": "1.0.0",
"description": "mmall前端代码",
"main": "index.js",
"scripts": {
"dev" : "WEBPACK_ENV=dev webpack-dev-server --inline --port 8088",
"dev_win" : "set WEBPACK_ENV=dev && webpack-dev-server --inline --port 8088",
"dist" : "WEBPACK_ENV=online webpack -p",
"dist_win" : "set WEBPACK_ENV=online && webpack -p"
},
"repository": {
"type": "git",
"url": "git@gitee.com:blemon/mmall_view.git"
},
"author": "Blemon",
"license": "ISC",
"devDependencies": {
"css-loader": "^0.28.10",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^1.1.11",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.0.6",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"webpack": "^1.15.0",
"webpack-dev-server": "^1.16.5"
},
"dependencies": {}
}
两个指令都不行
我看第二是说是什么node.js和npm不是最新还是什么
1回答
-
天热就吃哈密瓜
提问者
2018-03-13
刚才忘了传图了老师
WEBPACK_ENV=dev webpack-dev-server --inline --port 8088 这个指令就可以
062018-03-13
相似问题
回答 3
回答 2
回答 1
回答 1
回答 1