为了账号安全,请及时绑定邮箱和手机立即绑定

打包时报错

打包时报错


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应用
  • 参与学习       84610    人
  • 解答问题       786    个

用前端最热门框架Vue+最火打包工具Webpack打造todo应用

进入课程

打包时报错

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信