mirror of https://github.com/nuxt/nuxt.git
generate dist lib
This commit is contained in:
parent
59408bd329
commit
09e637cf4b
|
@ -1,2 +0,0 @@
|
||||||
# Excludes examples
|
|
||||||
examples
|
|
|
@ -246,7 +246,7 @@ Promise.all(resolveComponents)
|
||||||
// Hot reloading
|
// Hot reloading
|
||||||
if (module.hot) hotReloadAPI(_app)
|
if (module.hot) hotReloadAPI(_app)
|
||||||
// Call window.onNuxtReady callbacks
|
// Call window.onNuxtReady callbacks
|
||||||
nuxtReady(_app)
|
Vue.nextTick(() => nuxtReady(_app))
|
||||||
}
|
}
|
||||||
<% if (store) { %>
|
<% if (store) { %>
|
||||||
// Replace store state
|
// Replace store state
|
||||||
|
|
|
@ -10,6 +10,8 @@ const pify = require('pify')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const { createBundleRenderer } = require('vue-server-renderer')
|
const { createBundleRenderer } = require('vue-server-renderer')
|
||||||
const { join, resolve, sep, posix } = require('path')
|
const { join, resolve, sep, posix } = require('path')
|
||||||
|
const clientWebpackConfig = require('./webpack/client.config.js')
|
||||||
|
const serverWebpackConfig = require('./webpack/server.config.js')
|
||||||
const basename = posix.basename
|
const basename = posix.basename
|
||||||
const remove = pify(fs.remove)
|
const remove = pify(fs.remove)
|
||||||
const readFile = pify(fs.readFile)
|
const readFile = pify(fs.readFile)
|
||||||
|
@ -182,8 +184,8 @@ function * generateRoutesAndFiles () {
|
||||||
loading: (typeof this.options.loading === 'string' ? r(this.srcDir, this.options.loading) : this.options.loading),
|
loading: (typeof this.options.loading === 'string' ? r(this.srcDir, this.options.loading) : this.options.loading),
|
||||||
transition: this.options.transition,
|
transition: this.options.transition,
|
||||||
components: {
|
components: {
|
||||||
Loading: r(__dirname, '..', 'app', 'components', 'nuxt-loading.vue'),
|
Loading: r(__dirname, 'app', 'components', 'nuxt-loading.vue'),
|
||||||
ErrorPage: r(__dirname, '..', 'app', 'components', 'nuxt-error.vue')
|
ErrorPage: r(__dirname, 'app', 'components', 'nuxt-error.vue')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (templateVars.loading === 'string' && templateVars.loading.slice(-4) !== '.vue') {
|
if (templateVars.loading === 'string' && templateVars.loading.slice(-4) !== '.vue') {
|
||||||
|
@ -211,7 +213,7 @@ function * generateRoutesAndFiles () {
|
||||||
templateVars.components.ErrorPage = r(this.srcDir, 'layouts/error.vue')
|
templateVars.components.ErrorPage = r(this.srcDir, 'layouts/error.vue')
|
||||||
}
|
}
|
||||||
let moveTemplates = templatesFiles.map((file) => {
|
let moveTemplates = templatesFiles.map((file) => {
|
||||||
return readFile(r(__dirname, '..', 'app', file), 'utf8')
|
return readFile(r(__dirname, 'app', file), 'utf8')
|
||||||
.then((fileContent) => {
|
.then((fileContent) => {
|
||||||
const template = _.template(fileContent)
|
const template = _.template(fileContent)
|
||||||
const content = template(templateVars)
|
const content = template(templateVars)
|
||||||
|
@ -222,13 +224,11 @@ function * generateRoutesAndFiles () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebpackClientConfig () {
|
function getWebpackClientConfig () {
|
||||||
const clientConfigPath = r(__dirname, 'webpack', 'client.config.js')
|
return clientWebpackConfig.call(this)
|
||||||
return require(clientConfigPath).call(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebpackServerConfig () {
|
function getWebpackServerConfig () {
|
||||||
const configServerPath = r(__dirname, 'webpack', 'server.config.js')
|
return serverWebpackConfig.call(this)
|
||||||
return require(configServerPath).call(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWebpackMiddlewares () {
|
function createWebpackMiddlewares () {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const { urlJoin } = require('../../utils')
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
const nodeModulesDir = join(__dirname, '..', '..', '..', 'node_modules')
|
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
||||||
let config = {
|
let config = {
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
entry: {
|
entry: {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
const base = require('./base.config')
|
const base = require('./base.config.js')
|
||||||
const { resolve } = require('path')
|
const { resolve } = require('path')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const base = require('./base.config')
|
const base = require('./base.config.js')
|
||||||
const { uniq } = require('lodash')
|
const { uniq } = require('lodash')
|
||||||
const { existsSync } = require('fs')
|
const { existsSync, readFileSync } = require('fs')
|
||||||
const { resolve } = require('path')
|
const { resolve } = require('path')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -40,11 +40,14 @@ module.exports = function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Externals
|
// Externals
|
||||||
const nuxtPackageJson = require(resolve(__dirname, '..', '..', '..', 'package.json'))
|
const nuxtPackageJson = require('../../../package.json')
|
||||||
const projectPackageJson = resolve(this.dir, 'package.json')
|
const projectPackageJsonPath = resolve(this.dir, 'package.json')
|
||||||
config.externals = Object.keys(nuxtPackageJson.dependencies || {})
|
config.externals = Object.keys(nuxtPackageJson.dependencies || {})
|
||||||
if (existsSync(projectPackageJson)) {
|
if (existsSync(projectPackageJsonPath)) {
|
||||||
config.externals = config.externals.concat(Object.keys(require(projectPackageJson).dependencies || {}))
|
try {
|
||||||
|
const projectPackageJson = JSON.parse(readFileSync(projectPackageJsonPath))
|
||||||
|
config.externals = config.externals.concat(Object.keys(projectPackageJson.dependencies || {}))
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
config.externals = uniq(config.externals)
|
config.externals = uniq(config.externals)
|
||||||
|
|
||||||
|
|
25
package.json
25
package.json
|
@ -10,12 +10,16 @@
|
||||||
"name": "Alexandre Chopin"
|
"name": "Alexandre Chopin"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "index.js",
|
"main": "./dist/nuxt.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/nuxt/nuxt.js"
|
"url": "git+https://github.com/nuxt/nuxt.js"
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"bin",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"nuxt",
|
"nuxt",
|
||||||
"nuxt.js",
|
"nuxt.js",
|
||||||
|
@ -31,15 +35,20 @@
|
||||||
"nuxt": "./bin/nuxt"
|
"nuxt": "./bin/nuxt"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run lint",
|
"test": "nyc ava test/",
|
||||||
"lint": "eslint --ext .js,.vue bin lib pages test index.js --ignore-pattern lib/app",
|
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||||
"precommit": "npm run lint"
|
"lint": "eslint --ext .js,.vue bin lib pages test --ignore-pattern lib/app",
|
||||||
|
"build": "webpack",
|
||||||
|
"watch": "webpack --watch",
|
||||||
|
"precommit": "npm run lint",
|
||||||
|
"prepublish": "npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-html": "^0.0.6",
|
"ansi-html": "^0.0.6",
|
||||||
"autoprefixer": "^6.5.3",
|
"autoprefixer": "^6.5.3",
|
||||||
"babel-core": "^6.18.2",
|
"babel-core": "^6.18.2",
|
||||||
"babel-loader": "^6.2.8",
|
"babel-loader": "^6.2.8",
|
||||||
|
"babel-polyfill": "^6.20.0",
|
||||||
"babel-preset-es2015": "^6.18.0",
|
"babel-preset-es2015": "^6.18.0",
|
||||||
"babel-preset-stage-2": "^6.18.0",
|
"babel-preset-stage-2": "^6.18.0",
|
||||||
"chokidar": "^1.6.1",
|
"chokidar": "^1.6.1",
|
||||||
|
@ -73,12 +82,18 @@
|
||||||
"webpack-hot-middleware": "^2.13.2"
|
"webpack-hot-middleware": "^2.13.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"ava": "^0.17.0",
|
||||||
"babel-eslint": "^7.1.1",
|
"babel-eslint": "^7.1.1",
|
||||||
|
"codecov": "^1.0.1",
|
||||||
|
"copy-webpack-plugin": "^4.0.1",
|
||||||
"eslint": "^3.10.2",
|
"eslint": "^3.10.2",
|
||||||
"eslint-config-standard": "^6.2.1",
|
"eslint-config-standard": "^6.2.1",
|
||||||
"eslint-plugin-html": "^1.7.0",
|
"eslint-plugin-html": "^1.7.0",
|
||||||
"eslint-plugin-promise": "^3.4.0",
|
"eslint-plugin-promise": "^3.4.0",
|
||||||
"eslint-plugin-standard": "^2.0.1",
|
"eslint-plugin-standard": "^2.0.1",
|
||||||
"nodemon": "^1.11.0"
|
"jsdom": "^9.8.3",
|
||||||
|
"json-loader": "^0.5.4",
|
||||||
|
"nyc": "^10.0.0",
|
||||||
|
"webpack-node-externals": "^1.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
var nodeExternals = require('webpack-node-externals')
|
||||||
|
var CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
|
var resolve = require('path').resolve
|
||||||
|
var r = function (p) { return resolve(__dirname, p) }
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
target: 'node',
|
||||||
|
node: {
|
||||||
|
__dirname: false,
|
||||||
|
__filename: false
|
||||||
|
},
|
||||||
|
devtool: 'source-map',
|
||||||
|
entry: ['babel-polyfill', r('./lib/nuxt.js')],
|
||||||
|
output: {
|
||||||
|
path: r('./dist'),
|
||||||
|
filename: 'nuxt.js',
|
||||||
|
libraryTarget: 'commonjs2'
|
||||||
|
},
|
||||||
|
externals: [
|
||||||
|
nodeExternals({
|
||||||
|
whitelist: ['babel-polyfill']
|
||||||
|
})
|
||||||
|
],
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.json$/,
|
||||||
|
loader: 'json-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
loader: 'babel-loader',
|
||||||
|
exclude: /node_modules/,
|
||||||
|
query: {
|
||||||
|
presets: [
|
||||||
|
['es2015', { modules: false }],
|
||||||
|
'stage-2'
|
||||||
|
],
|
||||||
|
cacheDirectory: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new CopyWebpackPlugin([
|
||||||
|
{ from: 'lib/app', to: 'app' },
|
||||||
|
{ from: 'lib/views', to: 'views' }
|
||||||
|
])
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue