Skip to content

Commit 16f9e96

Browse files
committed
initial commit
0 parents  commit 16f9e96

36 files changed

+7995
-0
lines changed

.babelrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false
5+
}],
6+
"stage-2"
7+
],
8+
"plugins": ["transform-runtime"],
9+
"env": {
10+
"test": {
11+
"presets": ["env", "stage-2"] }
12+
}
13+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/build/
2+
/config/
3+
/dist/
4+
/*.js
5+
/test/unit/coverage/

.eslintrc.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// https://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
env: {
10+
browser: true,
11+
},
12+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
13+
extends: 'standard',
14+
// required to lint *.vue files
15+
plugins: [
16+
'html'
17+
],
18+
// add your custom rules here
19+
'rules': {
20+
// allow paren-less arrow functions
21+
'arrow-parens': 0,
22+
// allow async-await
23+
'generator-star-spacing': 0,
24+
// allow debugger during development
25+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26+
}
27+
}

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
node_modules/
3+
/dist/
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
/test/unit/coverage/
8+
/test/e2e/reports/
9+
selenium-debug.log
10+
11+
# Editor directories and files
12+
.idea
13+
.vscode
14+
*.suo
15+
*.ntvs*
16+
*.njsproj
17+
*.sln

.postcssrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
// to edit target browsers: use "browserslist" field in package.json
6+
"postcss-import": {},
7+
"autoprefixer": {}
8+
}
9+
}

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# django-vue-template
2+
3+
> A Vue.js and Django example
4+
5+
## Build Setup
6+
7+
``` bash
8+
# install dependencies
9+
npm install
10+
11+
# serve with hot reload at localhost:8080
12+
npm run dev
13+
14+
# build for production with minification
15+
npm run build
16+
17+
# build for production and view the bundle analyzer report
18+
npm run build --report
19+
20+
# run unit tests
21+
npm run unit
22+
23+
# run e2e tests
24+
npm run e2e
25+
26+
# run all tests
27+
npm test
28+
```
29+
30+
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

build/build.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict'
2+
require('./check-versions')()
3+
4+
process.env.NODE_ENV = 'production'
5+
6+
const ora = require('ora')
7+
const rm = require('rimraf')
8+
const path = require('path')
9+
const chalk = require('chalk')
10+
const webpack = require('webpack')
11+
const config = require('../config')
12+
const webpackConfig = require('./webpack.prod.conf')
13+
14+
const spinner = ora('building for production...')
15+
spinner.start()
16+
17+
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18+
if (err) throw err
19+
webpack(webpackConfig, function (err, stats) {
20+
spinner.stop()
21+
if (err) throw err
22+
process.stdout.write(stats.toString({
23+
colors: true,
24+
modules: false,
25+
children: false,
26+
chunks: false,
27+
chunkModules: false
28+
}) + '\n\n')
29+
30+
if (stats.hasErrors()) {
31+
console.log(chalk.red(' Build failed with errors.\n'))
32+
process.exit(1)
33+
}
34+
35+
console.log(chalk.cyan(' Build complete.\n'))
36+
console.log(chalk.yellow(
37+
' Tip: built files are meant to be served over an HTTP server.\n' +
38+
' Opening index.html over file:// won\'t work.\n'
39+
))
40+
})
41+
})

build/check-versions.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict'
2+
const chalk = require('chalk')
3+
const semver = require('semver')
4+
const packageConfig = require('../package.json')
5+
const shell = require('shelljs')
6+
function exec (cmd) {
7+
return require('child_process').execSync(cmd).toString().trim()
8+
}
9+
10+
const versionRequirements = [
11+
{
12+
name: 'node',
13+
currentVersion: semver.clean(process.version),
14+
versionRequirement: packageConfig.engines.node
15+
}
16+
]
17+
18+
if (shell.which('npm')) {
19+
versionRequirements.push({
20+
name: 'npm',
21+
currentVersion: exec('npm --version'),
22+
versionRequirement: packageConfig.engines.npm
23+
})
24+
}
25+
26+
module.exports = function () {
27+
const warnings = []
28+
for (let i = 0; i < versionRequirements.length; i++) {
29+
const mod = versionRequirements[i]
30+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
31+
warnings.push(mod.name + ': ' +
32+
chalk.red(mod.currentVersion) + ' should be ' +
33+
chalk.green(mod.versionRequirement)
34+
)
35+
}
36+
}
37+
38+
if (warnings.length) {
39+
console.log('')
40+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
41+
console.log()
42+
for (let i = 0; i < warnings.length; i++) {
43+
const warning = warnings[i]
44+
console.log(' ' + warning)
45+
}
46+
console.log()
47+
process.exit(1)
48+
}
49+
}

build/logo.png

6.69 KB
Loading

build/utils.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
'use strict'
2+
const path = require('path')
3+
const config = require('../config')
4+
const ExtractTextPlugin = require('extract-text-webpack-plugin')
5+
const pkg = require('../package.json')
6+
7+
exports.assetsPath = function (_path) {
8+
const assetsSubDirectory = process.env.NODE_ENV === 'production'
9+
? config.build.assetsSubDirectory
10+
: config.dev.assetsSubDirectory
11+
return path.posix.join(assetsSubDirectory, _path)
12+
}
13+
14+
exports.cssLoaders = function (options) {
15+
options = options || {}
16+
17+
const cssLoader = {
18+
loader: 'css-loader',
19+
options: {
20+
sourceMap: options.sourceMap
21+
}
22+
}
23+
24+
var postcssLoader = {
25+
loader: 'postcss-loader',
26+
options: {
27+
sourceMap: options.sourceMap
28+
}
29+
}
30+
31+
// generate loader string to be used with extract text plugin
32+
function generateLoaders (loader, loaderOptions) {
33+
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
34+
if (loader) {
35+
loaders.push({
36+
loader: loader + '-loader',
37+
options: Object.assign({}, loaderOptions, {
38+
sourceMap: options.sourceMap
39+
})
40+
})
41+
}
42+
43+
// Extract CSS when that option is specified
44+
// (which is the case during production build)
45+
if (options.extract) {
46+
return ExtractTextPlugin.extract({
47+
use: loaders,
48+
fallback: 'vue-style-loader'
49+
})
50+
} else {
51+
return ['vue-style-loader'].concat(loaders)
52+
}
53+
}
54+
55+
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
56+
return {
57+
css: generateLoaders(),
58+
postcss: generateLoaders(),
59+
less: generateLoaders('less'),
60+
sass: generateLoaders('sass', { indentedSyntax: true }),
61+
scss: generateLoaders('sass'),
62+
stylus: generateLoaders('stylus'),
63+
styl: generateLoaders('stylus')
64+
}
65+
}
66+
67+
// Generate loaders for standalone style files (outside of .vue)
68+
exports.styleLoaders = function (options) {
69+
const output = []
70+
const loaders = exports.cssLoaders(options)
71+
for (const extension in loaders) {
72+
const loader = loaders[extension]
73+
output.push({
74+
test: new RegExp('\\.' + extension + '$'),
75+
use: loader
76+
})
77+
}
78+
return output
79+
}
80+
81+
exports.createNotifierCallback = function () {
82+
const notifier = require('node-notifier')
83+
84+
return (severity, errors) => {
85+
if (severity !== 'error') {
86+
return
87+
}
88+
const error = errors[0]
89+
90+
const filename = error.file.split('!').pop()
91+
notifier.notify({
92+
title: pkg.name,
93+
message: severity + ': ' + error.name,
94+
subtitle: filename || '',
95+
icon: path.join(__dirname, 'logo.png')
96+
})
97+
}
98+
}

build/vue-loader.conf.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
const utils = require('./utils')
3+
const config = require('../config')
4+
const isProduction = process.env.NODE_ENV === 'production'
5+
const sourceMapEnabled = isProduction
6+
? config.build.productionSourceMap
7+
: config.dev.cssSourceMap
8+
9+
10+
module.exports = {
11+
loaders: utils.cssLoaders({
12+
sourceMap: sourceMapEnabled,
13+
extract: isProduction
14+
}),
15+
cssSourceMap: sourceMapEnabled,
16+
transformToRequire: {
17+
video: 'src',
18+
source: 'src',
19+
img: 'src',
20+
image: 'xlink:href'
21+
}
22+
}

0 commit comments

Comments
 (0)