Open JacobGit opened 6 years ago
Because of the use of ES6.
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('node_modules/@mvpleung/flipclock')]
}
ReferenceError: resolve is not defined occurs when adding this
const path = require('path');
function resolve(dir) {
return path.join(__dirname, '..', dir);
}
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();
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?