I finally use this webpack config:
const path = require('path');
require('dotenv').config();
module.exports = {
devtool: process.env.NODE_ENV === 'development' ? 'inline-source-map' :
false,
entry: './src/index.js',
output: {
filename: 'SyncAdaptor.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: 'commonjs',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
optimization: {
minimize: process.env.NODE_ENV !== 'development',
},
externals: [],
};
在此输入代码...
And use a index.js to guard if it's browser:
// prevent execution on server side, or there will be ReferenceError:
window is not defined raised from solid-auth-client
if (typeof window !== 'undefined') {
require('./SyncAdaptor');
}
Then it's fine to import browser only npm packages.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/01e4852d-a2ec-40e1-8acb-194f268074ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.