Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getWebpackConfig() {
// Use VueService to create full webpack config for us:
const plugins = [{ id: '@vue/cli-plugin-babel', apply: vuePluginBabel }]
if (this.config.build.eslint) {
plugins.push({ id: '@vue/cli-plugin-eslint', apply: vuePluginEslint })
}
const service = new VueService(this.getPath('build'), {
inlineOptions: this.getVueConfig(),
plugins
})
service.init(this.mode)
return service.resolveWebpackConfig()
}
}
// remove duplicated plugins
plugins: merge({
customizeArray: merge.unique(
"plugins",
[
"HotModuleReplacementPlugin",
"CaseSensitivePathsPlugin",
"WatchMissingNodeModulesPlugin"
],
plugin => plugin.constructor && plugin.constructor.name
)
})(vueConfig, storybookConfig).plugins,
resolve: {
...vueConfig.resolve,
alias: {
...vueConfig.resolve.alias,
vue$: storybookConfig.resolve.alias.vue$
}
}
};
};
entry: storybookConfig.entry, // overwite entry
output: storybookConfig.output, // overwrite output
// remove duplicated plugins
plugins: merge({
customizeArray: merge.unique(
"plugins",
[
"HotModuleReplacementPlugin",
"CaseSensitivePathsPlugin",
"WatchMissingNodeModulesPlugin"
],
plugin => plugin.constructor && plugin.constructor.name
)
})(vueConfig, storybookConfig).plugins,
resolve: {
...vueConfig.resolve,
alias: {
...vueConfig.resolve.alias,
vue$: storybookConfig.resolve.alias.vue$
}
}
};
};
serverCompiler.watch({}, (err, stats) =>{
if (err) {
throw err
}
stats = stats.toJson()
stats.errors.forEach(error => console.error(error) )
stats.warnings.forEach( warn => console.warn(warn) )
const bundlePath = path.join(
webpackConfig.output.path,
'vue-ssr-server-bundle.json'
)
bundle = JSON.parse(mfs.readFileSync(bundlePath,'utf-8'))
console.log('new bundle generated')
})
async findServerUrl (args, defaults) {
const useHttps = coalesce(args.https, defaults.https);
const protocol = useHttps ? 'https' : 'http';
const host = coalesce(args.host, process.env.HOST, defaults.host);
const port = await findPort(coalesce(args.port, process.env.PORT, defaults.port));
const urls = prepareURLs(protocol, host, port);
return {
protocol,
host,
port,
path,
networkUrl: urls.lanUrlForTerminal,
localUrl: format({ protocol, hostname: host, port, pathname: '/' }),
localUrlForTerminal: urls.localUrlForTerminal,
localUrlForBrowser: urls.localUrlForBrowser,
};
},
};