【问题标题】:Dist folder is not created after building vue js project构建vue js项目后未创建dist文件夹
【发布时间】:2019-02-28 13:15:41
【问题描述】:

我尝试在我的 vue 项目上运行 npm run build 命令。它成功运行,但没有创建 dist 文件夹。我想构建这个项目并在服务器上运行它。我目前正在使用 Windows 操作系统。 我尝试将它与其他项目的 webpack 文件进行比较,但没有发现任何差异。

var path = require('path')
var webpack = require('webpack')

module.exports = {
entry: './src/main.js',
output: {
 path: path.resolve(__dirname, './dist'),
 publicPath: '/dist/',
 filename: 'build.js'
},
 module: {
 rules: [
   {
     test: /\.css$/,
     use: [
       'vue-style-loader',
       'css-loader'
     ],
   },
   {
     test: /\.scss$/,
     use: [
       'vue-style-loader',
       'css-loader',
       'sass-loader'
     ],
   },
   {
     test: /\.sass$/,
     use: [
       'vue-style-loader',
       'css-loader',
       'sass-loader?indentedSyntax'
     ],
   },
   {
     test: /\.vue$/,
     loader: 'vue-loader',
     options: {
      loaders: {
        // Since sass-loader (weirdly) has SCSS as its default parse 
 mode, we map
        // the "scss" and "sass" values for the lang attribute to the 
 right configs here.
        // other preprocessors should work out of the box, no loader 
 config like this necessary.
        'scss': [
          'vue-style-loader',
          'css-loader',
          'sass-loader'
        ],
        'sass': [
          'vue-style-loader',
          'css-loader',
          'sass-loader?indentedSyntax'
        ]
      }
      // other vue-loader options go here
    }
   },
   {
     test: /\.js$/,
     loader: 'babel-loader',
     exclude: /node_modules/
   },
   {
      test: /\.(png|jpg|gif|svg)$/,
      loader: 'file-loader',
      options: {
       name: '[name].[ext]?[hash]'
      }
    }
  ]
},
resolve: {
  alias: {
    'vue$': 'vue/dist/vue.esm.js'
  },
 extensions: ['*', '.js', '.vue', '.json']
 },
 devServer: {
  historyApiFallback: true,
  noInfo: true,
  overlay: true
  },
 performance: {
 hints: false
 },
 devtool: '#eval-source-map'
 }

 if (process.env.NODE_ENV === 'production') {
 module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
 new webpack.DefinePlugin({
   'process.env': {
     NODE_ENV: '"production"'
  }
 }),
  new webpack.optimize.UglifyJsPlugin({
   sourceMap: true,
   compress: {
     warnings: false
   }
  }),
  new webpack.LoaderOptionsPlugin({
    minimize: true
  })
])
}

这是我的 webpack 配置文件。请帮我解决这个问题。

【问题讨论】:

  • 你能把你的项目上传到 Github 吗?
  • 不,我不能。这是我公司的项目,所以我不能。

标签: vue.js vuex


【解决方案1】:

尝试检查webpack配置文件所在的位置是否创建了一个文件夹。如果没有,你的其他配置似乎有问题,你可以试试这个,它在项目中对我来说很好:

output: {
    path: path.resolve(__dirname, '../dist'),
    filename: 'build.js',
    publicPath: './static'
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多