forked from vuestorefront/vue-storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
9,895 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": [["es2015", { "modules": false }], "stage-2"], | ||
"ignore": ["node_modules/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
sourceType: 'module' | ||
}, | ||
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style | ||
extends: 'standard', | ||
// required to lint *.vue files | ||
plugins: [ | ||
'html' | ||
], | ||
// add your custom rules here | ||
'rules': { | ||
// allow paren-less arrow functions | ||
'arrow-parens': 0, | ||
// allow async-await | ||
'generator-star-spacing': 0, | ||
// allow debugger during development | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
node_modules/ | ||
dist/ | ||
npm-debug.log | ||
.vscode/ | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
- "7" | ||
script: npm run unit --single-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
const MFS = require('memory-fs') | ||
const clientConfig = require('./webpack.client.config') | ||
const serverConfig = require('./webpack.server.config') | ||
|
||
module.exports = function setupDevServer (app, cb) { | ||
let bundle | ||
let template | ||
|
||
// modify client config to work with hot middleware | ||
clientConfig.entry.app = ['webpack-hot-middleware/client', clientConfig.entry.app] | ||
clientConfig.output.filename = '[name].js' | ||
clientConfig.plugins.push( | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NoEmitOnErrorsPlugin() | ||
) | ||
|
||
// dev middleware | ||
const clientCompiler = webpack(clientConfig) | ||
const devMiddleware = require('webpack-dev-middleware')(clientCompiler, { | ||
publicPath: clientConfig.output.publicPath, | ||
stats: { | ||
colors: true, | ||
chunks: false | ||
} | ||
}) | ||
app.use(devMiddleware) | ||
clientCompiler.plugin('done', () => { | ||
const fs = devMiddleware.fileSystem | ||
const filePath = path.join(clientConfig.output.path, 'index.html') | ||
if (fs.existsSync(filePath)) { | ||
template = fs.readFileSync(filePath, 'utf-8') | ||
if (bundle) { | ||
cb(bundle, template) | ||
} | ||
} | ||
}) | ||
|
||
// hot middleware | ||
app.use(require('webpack-hot-middleware')(clientCompiler)) | ||
|
||
// watch and update server renderer | ||
const serverCompiler = webpack(serverConfig) | ||
const mfs = new MFS() | ||
serverCompiler.outputFileSystem = mfs | ||
serverCompiler.watch({}, (err, stats) => { | ||
if (err) throw err | ||
stats = stats.toJson() | ||
stats.errors.forEach(err => console.error(err)) | ||
stats.warnings.forEach(err => console.warn(err)) | ||
|
||
// read bundle generated by vue-ssr-webpack-plugin | ||
const bundlePath = path.join(serverConfig.output.path, 'vue-ssr-bundle.json') | ||
bundle = JSON.parse(mfs.readFileSync(bundlePath, 'utf-8')) | ||
if (template) { | ||
cb(bundle, template) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module.exports = { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const path = require('path') | ||
// const projectRoot = path.resolve(__dirname, '../') | ||
const vueConfig = require('./vue-loader.config') | ||
|
||
module.exports = { | ||
devtool: '#source-map', | ||
entry: { | ||
app: './src/client-entry.js', | ||
vendor: ['vue', 'vue-router', 'vuex', 'vuex-router-sync', 'axios'] | ||
}, | ||
resolve: { | ||
modules: [path.resolve(__dirname, 'src'), 'node_modules'], | ||
extensions: ['.js', '.vue'], | ||
alias: { | ||
'src': path.resolve(__dirname, '../src'), | ||
'assets': path.resolve(__dirname, '../src/assets'), | ||
'components': path.resolve(__dirname, '../src/components') | ||
} | ||
}, | ||
|
||
output: { | ||
path: path.resolve(__dirname, '../dist'), | ||
publicPath: '/dist/', | ||
filename: 'client-bundle.[chunkhash].js' | ||
}, | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
enforce: 'pre', | ||
test: /\.js$/, | ||
loader: 'eslint-loader', | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
enforce: 'pre', | ||
test: /\.vue$/, | ||
loader: 'eslint-loader', | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader', | ||
options: vueConfig | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.(png|jpg|gif|svg)$/, | ||
loader: 'file-loader', | ||
options: { | ||
name: '[name].[ext]?[hash]' | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const webpack = require('webpack') | ||
const merge = require('webpack-merge') | ||
const base = require('./webpack.base.config') | ||
const vueConfig = require('./vue-loader.config') | ||
const HTMLPlugin = require('html-webpack-plugin') | ||
const SWPrecachePlugin = require('sw-precache-webpack-plugin') | ||
|
||
const config = merge(base, { | ||
resolve: { | ||
alias: { | ||
'create-api': './create-api-client.js' | ||
} | ||
}, | ||
plugins: [ | ||
// strip dev-only code in Vue source | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'), | ||
'process.env.VUE_ENV': '"client"' | ||
}), | ||
// extract vendor chunks for better caching | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor' | ||
}), | ||
// generate output HTML | ||
new HTMLPlugin({ | ||
template: 'src/index.template.html' | ||
}) | ||
] | ||
}) | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
config.plugins.push( | ||
// minify JS | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
warnings: false | ||
} | ||
}), | ||
// auto generate service worker | ||
new SWPrecachePlugin({ | ||
cacheId: 'vue-hn', | ||
filename: 'service-worker.js', | ||
dontCacheBustUrlsMatching: /./, | ||
staticFileGlobsIgnorePatterns: [/index\.html$/, /\.map$/] | ||
}) | ||
) | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const webpack = require('webpack') | ||
const merge = require('webpack-merge') | ||
const base = require('./webpack.base.config') | ||
const VueSSRPlugin = require('vue-ssr-webpack-plugin') | ||
|
||
module.exports = merge(base, { | ||
target: 'node', | ||
entry: './src/server-entry.js', | ||
output: { | ||
filename: 'server-bundle.js', | ||
libraryTarget: 'commonjs2' | ||
}, | ||
resolve: { | ||
alias: { | ||
'create-api': './create-api-server.js' | ||
} | ||
}, | ||
externals: Object.keys(require('../package.json').dependencies), | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'), | ||
'process.env.VUE_ENV': '"server"' | ||
}), | ||
new VueSSRPlugin() | ||
] | ||
}) |
Oops, something went wrong.