mvpleung / vue-flipclock

flipclock for Vue,Rejecting jQuery dependency( flipclock Vue 版本,剔除 jquery 依赖)
Apache License 2.0
20 stars 10 forks source link

Error on "npm run build" #5

Open JacobGit opened 6 years ago

JacobGit commented 6 years ago

I've implemented the flipclock in my Vue project, but whenever I go to build with npm run build, I get this error:

ERROR in vendor.18380e69.js from UglifyJs Unexpected token: operator (>) [./~/@mvpleung/flipclock/index.js:5,0][vendor.18380e69.js:60480,21]

Any thoughts?

mvpleung commented 6 years ago

Because of the use of ES6.

{
    test: /\.js$/,
    loader: 'babel-loader',
    include: [resolve('node_modules/@mvpleung/flipclock')]
}
dfranc3373 commented 6 years ago

ReferenceError: resolve is not defined occurs when adding this

mvpleung commented 6 years ago
const path = require('path');

function resolve(dir) {
  return path.join(__dirname, '..', dir);
}
ThomasVdBerge commented 5 years ago

I've added your suggested pieces of code to my webpack config file, but still getting the same error, but only when running yarn encore production. for yarn encore dev everything works fine.

ERROR Failed to compile with 1 errors9:45:01 AM

error

app.bc30a410.js from UglifyJs Unexpected token: operator (>) [app.bc30a410.js:12470,21]

My webpack file now looks like this:

var Encore = require("@symfony/webpack-encore");
const { VueLoaderPlugin } = require("vue-loader");
const path = require('path');

function resolve(dir) {
  return path.join(__dirname, '..', dir);
}

Encore.setOutputPath("public/build/")
  .setPublicPath("/build")

  .addEntry("app", "./resources/assets/js/app.js")

  .cleanupOutputBeforeBuild()
  .enableSourceMaps(!Encore.isProduction())
  .enableVersioning(Encore.isProduction())

  .addLoader({
    test: /\.vue$/,
    loader: "vue-loader"
  })
    .addLoader(
        {
            test: /\.js$/,
            loader: 'babel-loader',
            include: [resolve('node_modules/@mvpleung/flipclock')]
    })
  .addLoader({
    test: /\.(js|vue)$/,
    enforce: "pre",
    loader: "eslint-loader",
    exclude: /node_modules/,
    options: {
      fix: true
    }
  })
  .addPlugin(new VueLoaderPlugin())
  .addAliases({
    vue: "vue/dist/vue.js"
  })

  .enableSassLoader()
  .enablePostCssLoader()
;

module.exports = Encore.getWebpackConfig();