亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

打包時報錯

打包時報錯


ERROR in ./node_modules/.bin/webpack 1:0

Module parse failed: Unexpected character '#' (1:0)

You may need an appropriate loader to handle this file type.

> #!/bin/sh

| basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

|

Child html-webpack-plugin for "index.html":

? ? ?1 asset

? ? Entrypoint undefined = index.html

? ? ? ?4 modules


正在回答

2 回答

const?path?=?require('path')
const?VueLoaderPlugin?=?require('vue-loader/lib/plugin')
const?isDev?=?process.env.NODE_ENV?===?'development';
const?HTMLPlugin?=?require('html-webpack-plugin');
const?webpack?=?require('webpack');
//?const?ExtractPlugin=require('mini-css-extract-plugin')
const?ExtractPlugin=require('extract-text-webpack-plugin')
//?ExtractPlugin
//?const?MiniCssExtractPlugin?=?require('mini-css-extract-plugin')
//?定義輸出模塊
//?module.exports
const?config??={
target:'web',
//?拼接路徑,使其成為絕對路徑
entry:?path.join(__dirname,'./src/index.js'),
output:?{
????filename:?'bundle.js',
????path:?path.join(__dirname,'./dist')
},
module:?{
????rules:?[
??????{
????????test:?/\.vue$/,
????????loader:?'vue-loader'
??????},
??????{
????????test:?/\.css$/,
????????use:?[
????????'style-loader',
????????'css-loader'
????????]
??????},
{
test:/\.styl(us)?$/,
????????use:?ExtractPlugin.extract({
????????fallback:?'style-loader',
????????use:[
??????????{loader:'css-loader'},
{
loader?:?'postcss-loader',
options:??{
sourceMap:?true,
}
},
??????????{loader:'stylus-loader'}
????????]
????????})
},
??????{
????????test:?/\.jsx$/,
????????loader:?'babel-loader'
??????},
??????{
????????test:?/\.(gif|jpg|jpeg|png|svg)$/,
????????use:?[
??????????{
????????????loader:?'url-loader',
????????????options:{
??????????????limit:?1024,
??????????????name:?'[name].[ext]'
????????????}
??????????}
????????]
??????}
????]
},
??plugins:?[
new?webpack.DefinePlugin({

'process.env':?{
NODE_ENV:isDev?'"development"'?:'"production"'
}
}),
????//?請確保引入這個插件!
????new?VueLoaderPlugin(),
????new?HTMLPlugin(),
??]
}
if?(isDev)?{
//頁面調試工具?
config.devtool?=?'#cheap-module-eval-source-map'
//?開發環境端口
config.devServer?=?{
port:?8000,
????host:'0.0.0.0',
????historyApiFallback:true,
????overlay:?{
??????errors:true,
????},
//?熱加載,只渲染改變的組件,不需要重新渲染整個頁面
//?hot:?true不要和new?webpack.HotModuleReplacementPlugin()同時啟用
hot:?true
//?open:true
},
//?熱加載所需配置
config.plugins.push(
????//?new?webpack.HotModuleReplacementPlugin(),
????new?webpack.NoEmitOnErrorsPlugin()
??)
}
module.exports?=?config


0 回復 有任何疑惑可以回復我~

123

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Vue+Webpack打造todo應用
  • 參與學習       84618    人
  • 解答問題       812    個

用前端最熱門框架Vue+最火打包工具Webpack打造todo應用

進入課程

打包時報錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號