"scripts": {
"dev": "node build/dev-server.js",
...
}
The infusionsoft dev-server does most of the heavy lifting. It provides us:
You can view it here: https://github.com/infusionsoft/vue-build-system/blob/master/build/dev-server.js
const server = require('@infusionsoft/vue-build-system/build/dev-server.js');
const webpackConfig = require('./webpack.dev.config');
server.start(webpackConfig, 10229);
Infusionsoft’s webpack.dev.config pulls in the base config and then adds to it, enabling:
Source Maps
CDN wiring for webpack
Friendly errors plugin
const merge = require('webpack-merge');
const cdnOptions = require('./cdn');
const sharedDevWebpack = require('@infusionsoft/vue-build-system/build/webpack.dev.config')(cdnOptions);
const baseWebpack = require('./webpack.base.config');
module.exports = merge(sharedDevWebpack, baseWebpack);
The @infusionsoft/vue-build-system also handles:
Minifying/compressing code in prod
Vue and scss file compiling
Some eslinting
process.env.NODE_ENV js variable
Shortcut for the base location of where to find import definitions.
// build/webpack.base.config
const path = require('path');
module.exports = {
resolve: {
alias: {
app: path.resolve('./src/app'),
...
},
},
...
};
then in your component...
import Component from 'app/components/Component';
Remember in build?
// build/webpack.dev.config.js
const merge = require('webpack-merge');
const cdnOptions = require('./cdn');
const sharedDevWebpack = require('@infusionsoft/vue-build-system/build/webpack.dev.config')(cdnOptions);
const baseWebpack = require('./webpack.base.config');
module.exports = merge(sharedDevWebpack, baseWebpack);
// build/cdn.js
const path = require('path');
// get version from package.json
const version = (name) => {
return require(path.join(__dirname, '../node_modules', name, 'package.json')).version;
};
// if in dev don't get the minified version
const min = process.env.NODE_ENV !== 'dev';
const minCheck = min ? '.min' : '';
// using unpkg.com for cdn; this is usually reliable
const cdnjs = [
`//unpkg.com/vue@${version('vue')}/dist/vue${minCheck}.js`,
`//unpkg.com/vuex@${version('vuex')}/dist/vuex${minCheck}.js`,
`//unpkg.com/vue-router@${version('vue-router')}/dist/vue-router${minCheck}.js`,
`//unpkg.com/vue-i18n@${version('vue-i18n')}/dist/vue-i18n${minCheck}.js`,
`//unpkg.com/moment@${version('moment')}/min/moment-with-locales${minCheck}.js`,
];
const cdncss = [];
module.exports = {
cdnjs,
cdncss,
externals: {
vue: 'Vue',
vuex: 'Vuex',
'vue-router': 'VueRouter',
'vue-i18n': 'VueI18n',
moment: 'moment',
},
};
If you want to externalize a script, you would do it here
app/main.js
...
import Vue from 'vue';
const DesignSystem = require('@infusionsoft/design-system');
Vue.use(DesignSystem);
...
Now we have access to design system's
TEST your design-system changes with the web app
design-system> yarn dist:debug // builds js/css bundle
design-system> yarn link // creates a symlinkable folder for d-s
your-project> yarn link @infusionsoft/design-system
// symlinks to what was created
Your-project> yarn dev
You can look in node_modules/@infusionsoft/design-system to make sure your d-s changes are there
Then when you tweak d-s, run yarn dist:debug again and your changes should show up without having to restart your web server
TL;DR:
// package.json
"dependencies": {
"@infusionsoft/design-system": "git+ssh://git@github.com/infusionsoft/design-system.git#~7.0.0",
"axios": "0.16.2",
"brace": "0.10.0",
"fastclick": "1.0.6",
"lodash.debounce": "4.0.8",
"moment": "2.18.1",
"vue": "2.5.9",
"vue-i18n": "7.0.4",
"vue-router": "2.7.0",
"vuedraggable": "^2.14.1",
"vuex": "3.0.1",
"vuex-persistedstate": "2.4.2"
},
// app/main.js
...
import Vue from 'vue';
import axios from 'axios';
axios.defaults.headers.put['Content-Type'] = 'application/json;charset=UTF-8';
Vue.prototype.$http = axios;
...
// app/main.js
...
import FastClick from 'fastclick';
...
FastClick.attach(document.body);
// package.json
"dependencies": {
"@infusionsoft/design-system": "git+ssh://git@github.com/infusionsoft/design-system.git#~7.0.0",
"axios": "0.16.2",
"brace": "0.10.0",
"fastclick": "1.0.6",
"lodash.debounce": "4.0.8",
"moment": "2.18.1",
"vue": "2.5.9",
"vue-i18n": "7.0.4",
"vue-router": "2.7.0",
"vuedraggable": "^2.14.1",
"vuex": "3.0.1",
"vuex-persistedstate": "2.4.2"
},
strat builder package.json dependencies
Note: these are Dependencies and not
dev-dependencies, which are different.
README - how to run tests
look at test command in package.json
go to karma.config.js
files: index.js
There's a confluence page for that https://wiki.infusionsoft.com/display/PD/Write+Good+Frontend+Unit+Tests