Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 15d6051

Browse files
fix(ssr): window is not defined
closes #252
1 parent 60d005f commit 15d6051

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

.babelrc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
{
2-
"presets": ["@babel/preset-env"]
3-
}
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": "last 3 versions, ie >= 9",
7+
"modules": false
8+
}
9+
]
10+
]
11+
}

webpack.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const path = require('path')
12
const TerserPlugin = require('terser-webpack-plugin')
23
const CompressionPlugin = require('compression-webpack-plugin')
34

@@ -7,7 +8,8 @@ module.exports = function (env, argv) {
78
return {
89
output: {
910
libraryTarget: 'umd',
10-
filename: 'vue-analytics.js'
11+
filename: 'vue-analytics.js',
12+
globalObject: 'typeof self !== \'undefined\' ? self : this'
1113
},
1214
optimization: {
1315
minimize: isProduction,
@@ -19,6 +21,15 @@ module.exports = function (env, argv) {
1921
})
2022
]
2123
},
24+
module: {
25+
rules: [
26+
{
27+
test: /\.js$/,
28+
include: path.resolve(__dirname, './src'),
29+
loader: 'babel-loader'
30+
}
31+
]
32+
},
2233
plugins: [
2334
...(isProduction ? [new CompressionPlugin()] : [])
2435
]

0 commit comments

Comments
 (0)