mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-05-03 02:20:59 -05:00
@@ -1,3 +1,14 @@
|
||||
import Component from '~entry'
|
||||
;(function () {
|
||||
if (typeof window !== 'undefined') {
|
||||
let i
|
||||
if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js$/))) {
|
||||
__webpack_public_path__ = i[1] // eslint-disable-line
|
||||
}
|
||||
} else {
|
||||
__webpack_public_path__ = '/' // eslint-disable-line
|
||||
}
|
||||
})()
|
||||
|
||||
export default Component
|
||||
import mod from '~entry'
|
||||
export default mod
|
||||
export * from '~entry'
|
||||
|
||||
@@ -14,31 +14,6 @@ module.exports = (api, { entry, name }, options) => {
|
||||
function genConfig (format, postfix = format, genHTML) {
|
||||
const config = api.resolveChainableWebpackConfig()
|
||||
|
||||
config.entryPoints.clear()
|
||||
const entryName = `${libName}.${postfix}`
|
||||
// set proxy entry for *.vue files
|
||||
if (/\.vue$/.test(entry)) {
|
||||
config
|
||||
.entry(entryName)
|
||||
.add(require.resolve('./entry-lib.js'))
|
||||
config.resolve
|
||||
.alias
|
||||
.set('~entry', api.resolve(entry))
|
||||
} else {
|
||||
config
|
||||
.entry(entryName)
|
||||
.add(api.resolve(entry))
|
||||
}
|
||||
|
||||
config.output
|
||||
.filename(`${entryName}.js`)
|
||||
.chunkFilename(`${entryName}.[id].js`)
|
||||
.library(libName)
|
||||
.libraryExport('default')
|
||||
.libraryTarget(format)
|
||||
// use relative publicPath so this can be deployed anywhere
|
||||
.publicPath('./')
|
||||
|
||||
// adjust css output name so they write to the same file
|
||||
if (options.css.extract !== false) {
|
||||
config
|
||||
@@ -76,7 +51,32 @@ module.exports = (api, { entry, name }, options) => {
|
||||
}])
|
||||
}
|
||||
|
||||
return api.resolveWebpackConfig(config)
|
||||
// resolve entry/output
|
||||
const entryName = `${libName}.${postfix}`
|
||||
config.resolve
|
||||
.alias
|
||||
.set('~entry', api.resolve(entry))
|
||||
|
||||
// set entry/output after user configureWebpack hooks are applied
|
||||
const rawConfig = api.resolveWebpackConfig(config)
|
||||
|
||||
rawConfig.entry = {
|
||||
[entryName]: require.resolve('./entry-lib.js')
|
||||
}
|
||||
|
||||
Object.assign(rawConfig.output, {
|
||||
filename: `${entryName}.js`,
|
||||
chunkFilename: `${entryName}.[id].js`,
|
||||
library: libName,
|
||||
libraryExport: 'default',
|
||||
libraryTarget: format,
|
||||
// use dynamic publicPath so this can be deployed anywhere
|
||||
// the actual path will be determined at runtime by checking
|
||||
// document.currentScript.src.
|
||||
publicPath: ''
|
||||
})
|
||||
|
||||
return rawConfig
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -43,17 +43,6 @@ module.exports = (api, { target, entry, name }) => {
|
||||
function genConfig (minify, genHTML) {
|
||||
const config = api.resolveChainableWebpackConfig()
|
||||
|
||||
config.entryPoints.clear()
|
||||
const entryName = `${libName}${minify ? `.min` : ``}`
|
||||
|
||||
// set proxy entry for *.vue files
|
||||
config
|
||||
.entry(entryName)
|
||||
.add(dynamicEntry)
|
||||
config.resolve
|
||||
.alias
|
||||
.set('~root', api.resolve('.'))
|
||||
|
||||
// make sure not to transpile wc-wrapper
|
||||
config.module
|
||||
.rule('js')
|
||||
@@ -65,14 +54,6 @@ module.exports = (api, { target, entry, name }) => {
|
||||
config.plugins.delete('uglify')
|
||||
}
|
||||
|
||||
config.output
|
||||
.filename(`${entryName}.js`)
|
||||
.chunkFilename(`${libName}.[id]${minify ? `.min` : ``}.js`)
|
||||
// use dynamic publicPath so this can be deployed anywhere
|
||||
// the actual path will be determined at runtime by checking
|
||||
// document.currentScript.src.
|
||||
.publicPath('')
|
||||
|
||||
// externalize Vue in case user imports it
|
||||
config
|
||||
.externals({
|
||||
@@ -110,7 +91,31 @@ module.exports = (api, { target, entry, name }) => {
|
||||
}])
|
||||
}
|
||||
|
||||
return api.resolveWebpackConfig(config)
|
||||
// set entry/output last so it takes higher priority than user
|
||||
// configureWebpack hooks
|
||||
|
||||
// set proxy entry for *.vue files
|
||||
config.resolve
|
||||
.alias
|
||||
.set('~root', api.resolve('.'))
|
||||
|
||||
const rawConfig = api.resolveWebpackConfig(config)
|
||||
|
||||
const entryName = `${libName}${minify ? `.min` : ``}`
|
||||
rawConfig.entry = {
|
||||
[entryName]: dynamicEntry
|
||||
}
|
||||
|
||||
Object.assign(rawConfig.output, {
|
||||
filename: `${entryName}.js`,
|
||||
chunkFilename: `${libName}.[id]${minify ? `.min` : ``}.js`,
|
||||
// use dynamic publicPath so this can be deployed anywhere
|
||||
// the actual path will be determined at runtime by checking
|
||||
// document.currentScript.src.
|
||||
publicPath: ''
|
||||
})
|
||||
|
||||
return rawConfig
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user