Skip to content

Commit

Permalink
frontplate-cliを最新版にアップデート
Browse files Browse the repository at this point in the history
  • Loading branch information
sable-virt committed Oct 6, 2016
1 parent 45da3ac commit 708af33
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 66 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
{
"presets": [
["es2015", { "modules": false }]
]
}
3 changes: 2 additions & 1 deletion config/copy.config.js
Original file line number Diff line number Diff line change
@@ -1,3 1,4 @@
module.exports = {
"src/lib/**/*": "public/assets/lib"
// "path/from": "/path/to"
"src/lib/**/*": "public/assets/lib"
};
9 changes: 4 additions & 5 deletions config/html.config.js
Original file line number Diff line number Diff line change
@@ -1,11 1,10 @@
module.exports = {
src: 'src/view/**/*.ejs',
dest: 'public',
// ejs params
params: {
src: 'src/view/**/*.ejs', // 読み込むビューファイル
dest: 'public', // 出力先
params: { // ビューで使うグローバル変数
title: 'title'
},
// htmlhint rules
// htmlhintルール(https://github.com/yaniswang/HTMLHint/wiki/Rules)
rules: {
"tagname-lowercase": true,
"attr-lowercase": true,
Expand Down
4 changes: 2 additions & 2 deletions config/image.config.js
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
module.exports = {
src: 'src/images/*.{gif,jpg,png}',
dest: 'public/assets/images'
src: 'src/images/*.{gif,jpg,png}', // 読み込むイメージ
dest: 'public/assets/images' // 出力先
};
4 changes: 2 additions & 2 deletions config/server.config.js
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
'use strict';
module.exports = {
"server": 'public',
"port": 3000,
"server": 'public', // ドキュメントルート
"port": 3000, // ポート
"middleware": [
],
"ghostMode": {
Expand Down
10 changes: 5 additions & 5 deletions config/sprite.config.js
Original file line number Diff line number Diff line change
@@ -1,10 1,10 @@
'use strict';
module.exports = [
{
src: 'src/sprites/icon/*.{png,gif,jpg}',
destImage: 'src/images/icon.png',
destCSS: 'src/sass/sprites/_icon.scss',
imgPath: '../images/icon.png',
padding: 2
src: 'src/sprites/icon/*.{png,gif,jpg}', // 読み込む画像
destImage: 'src/images/icon.png', // 画像出力先
destCSS: 'src/sass/sprites/_icon.scss', // CSS出力先
imgPath: '../images/icon.png', // CSS内での画像パス
padding: 2 // 画像の間隔
}
];
8 changes: 4 additions & 4 deletions config/style.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 5,10 @@ const SUPPORT_BROWSERS = [
'Android >= 4.0'
];
module.exports = {
src: 'src/sass/**/*.scss',
dest: 'public/assets/css',
plugins: [
require('autoprefixer')({
src: 'src/sass/**/*.scss', // 読み込むscss
dest: 'public/assets/css', // 出力先
plugins: [ // postcssプラグイン
require('autoprefixer')({ // autoprefixer(https://github.com/postcss/autoprefixer)
browsers: SUPPORT_BROWSERS
})
]
Expand Down
21 changes: 13 additions & 8 deletions config/test.conf.js
Original file line number Diff line number Diff line change
@@ -1,25 1,30 @@
'use strict';
/**
* karma conf
* @param config
* url: https://karma-runner.github.io/1.0/config/configuration-file.html
*/
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
require.resolve('power-assert/build/power-assert'),
'src/js/**/*-spec.js'
],
preprocessors: {
'src/js/**/*-spec.js': ['babel']
'src/js/**/*-spec.js': ['webpack','babel']
},
babelPreprocessor: {
options: {
presets: ['es2015'],
sourceMap: 'inline'
}
webpack: {
resolve: { modules: [ './src/js'] },
},
webpackMiddleware: {
quiet: true,
stats: 'errors-only'
},
exclude: [],
// test results reporter to use
Expand Down
20 changes: 10 additions & 10 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 2,29 @@
const webpack = require("webpack");
const merge = require("webpack-merge");
const core = require("./webpack.core");
/**
* webpack config
* url: https://webpack.github.io/docs/configuration.html
*/
const webpackConfig = merge(core, {
debug: true,
devtool: '#source-map',
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
'webpack-espower-loader',
'babel?presets[]=es2015'
]
loader: 'babel?babelrc=' __dirname '/../.babelrc'
}
]
},
plugins: [
new webpack.ProvidePlugin({
assert: "power-assert",
}),
new webpack.DefinePlugin({
'NODE_ENV': 'development'
'process.env': {
'NODE_ENV': JSON.stringify('development')
}
}),
new webpack.BannerPlugin('console.warn("This script is development version.");', {
new webpack.BannerPlugin({
banner: 'console.warn("This script is development version.");',
raw: true
})
]
Expand Down
18 changes: 10 additions & 8 deletions config/webpack.config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 3,17 @@ const webpack = require("webpack");
const merge = require("webpack-merge");
const ClosureCompiler = require.main.require('google-closure-compiler-js').webpack;
const core = require("./webpack.core");
/**
* webpack config for production
* url: https://webpack.github.io/docs/configuration.html
*/
const webpackConfig = merge(core,{
devtool: '#source-map',
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
'webpack-unassert',
'babel?presets[]=es2015'
]
loader: 'babel?babelrc=' __dirname '/../.babelrc'
}
]
},
Expand All @@ -26,12 26,14 @@ const webpackConfig = merge(core,{
warningLevel: 'QUIET',
},
}),
//new webpack.optimize.CommonsChunkPlugin('app','app.js'),
// new webpack.optimize.CommonsChunkPlugin('app','app.js'),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'NODE_ENV': 'production'
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
],
});
Expand Down
24 changes: 16 additions & 8 deletions config/webpack.core.js
Original file line number Diff line number Diff line change
@@ -1,5 1,9 @@
'use strict';
const webpack = require("webpack");
/**
* webpack config
* url: https://webpack.github.io/docs/configuration.html
*/
const webpackConfig = {
entry: {
app: './src/js/app.js'
Expand All @@ -11,20 15,24 @@ const webpackConfig = {
sourceMapFilename: 'maps/[name].map',
jsonpFunction: 'fr'
},
resolve: { root: [ './src/js'] },
resolve: { modules: [ './src/js'] },
module: {
preLoaders: [
{test: /\.js$/, exclude: /node_modules/, loader: 'eslint'}
],
loaders: [
{test: /\.js$/, exclude: /node_modules/, loader: 'eslint', enforce: 'pre'},
{test: /\.html$/, loader: 'html'},
{test: /\.json$/, loader: 'json'},
],
exprContextCritical: false
},
eslint: {
configFile: __dirname '/../.eslintrc',
failOnError: true
}
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
eslint: {
configFile: __dirname '/../.eslintrc',
failOnError: true
}
}
})
]
};
module.exports = webpackConfig;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 4,13 @@
"description": "フロントエンド開発の効率をあげるフルスタックテンプレート",
"dependencies": {},
"devDependencies": {
"frontplate-cli": "^0.1.7"
"frontplate-cli": "^0.2.3"
},
"scripts": {
"start": "frp build && frp serve",
"start": "frp build && frp serve -t",
"test": "frp build",
"build": "frp build",
"serve": "frp serve",
"serve": "frp serve -t",
"production": "frp build -p",
"changelog": "conventional-changelog -p eslint -i CHANGELOG.md -w -s -r 0"
},
Expand Down
4 changes: 3 additions & 1 deletion src/js/app-spec.js
Original file line number Diff line number Diff line change
@@ -1,8 1,10 @@
import {App} from './app';
describe('app', () => {
beforeEach(() => {

});
it('init', () => {
assert('a' === 'a');
let app = new App('myapp');
expect(app.val).toBe('myapp');
});
});
9 changes: 5 additions & 4 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 2,13 @@ import 'sub/sub';
/**
* @constructor
*/
class Main {
export class App {
constructor(val) {
this.val = val;
}
}

let m = new Main('main');
assert(m.val === 'main', `Init val match`);
assert(m.val === 'sub', `Init val unmatch`);
let m = new App('main');
if (process.env.NODE_ENV === 'development') {
console.debug('main value:', m.val);
}
10 changes: 10 additions & 0 deletions src/js/sub/sub-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 1,10 @@
import {Sub} from 'sub/sub';
describe('app', () => {
beforeEach(() => {

});
it('init', () => {
let sub = new Sub('sub');
expect(sub.val).toBe('sub');
});
});
6 changes: 1 addition & 5 deletions src/js/sub/sub.js
Original file line number Diff line number Diff line change
@@ -1,12 1,8 @@
/**
* @constructor
*/
class Main {
export class Sub {
constructor(val) {
this.val = val;
}
}

let m = new Main('main');
assert(m.val === 'main', `Init val match`);
assert(m.val === 'sub', `Init val unmatch`);
1 change: 1 addition & 0 deletions src/sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 8,4 @@
@import 'base/base';
@import 'layout/layout';
@import 'sprites/icon';

0 comments on commit 708af33

Please sign in to comment.