Skip to content

Commit

Permalink
feat: Webpack 3 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkr00t committed Jul 19, 2017
1 parent ad9055b commit 5d0815b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 61 deletions.
66 changes: 25 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"name": "aik",
"version": "0.16.1",
"version": "0.16.2",
"description": "Frontend Playground",
"bin": "cli.js",
"main": "lib/index.js",
"files": [
"cli.js",
"lib/",
"template/"
],
"files": ["cli.js", "lib/", "template/"],
"keywords": [
"node",
"frontend",
Expand Down Expand Up @@ -55,52 +51,44 @@
"email": "d4rkr00t@gmail.com",
"url": "https://github.com/d4rkr00t/aik"
},
"pre-commit": [
"lint:flow",
"lint:staged",
"test"
],
"pre-commit": ["lint:flow", "lint:staged", "test"],
"lint-staged": {
"*.js": [
"eslint",
"prettier --write --print-width 120",
"git add"
]
"*.js": ["eslint", "prettier --write --print-width 120", "git add"]
},
"dependencies": {
"autoprefixer": "7.1.1",
"autoprefixer": "7.1.2",
"babel-core": "6.25.0",
"babel-loader": "7.0.0",
"babel-loader": "7.1.1",
"babel-polyfill": "6.23.0",
"babel-preset-env": "1.5.2",
"babel-preset-env": "1.6.0",
"babel-preset-react": "6.24.1",
"babel-preset-react-hmre": "1.1.1",
"chalk": "1.1.3",
"connect-history-api-fallback": "1.3.0",
"css-loader": "0.28.4",
"eslint": "4.0.0",
"eslint-loader": "1.8.0",
"eslint": "4.2.0",
"eslint-loader": "1.9.0",
"eslint-plugin-react": "7.1.0",
"extract-text-webpack-plugin": "2.1.2",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "0.11.2",
"fs-extra": "3.0.1",
"gzip-size": "3.0.0",
"html-loader": "0.4.5",
"html-webpack-plugin": "2.28.0",
"html-webpack-plugin": "2.29.0",
"insight": "0.8.4",
"json-loader": "0.5.4",
"meow": "3.7.0",
"ngrok": "2.2.9",
"npm-install-webpack2-plugin": "4.1.0",
"ngrok": "2.2.15",
"npm-install-webpack2-plugin": "5.0.1",
"opn": "5.1.0",
"postcss-loader": "2.0.5",
"postcss-loader": "2.0.6",
"postcss-partial-import": "4.1.0",
"precss": "1.4.0",
"precss": "2.0.0",
"react-hot-loader": "^3.0.0-beta.6",
"resolve": "1.3.3",
"style-loader": "0.18.2",
"webpack": "2.6.1",
"webpack-dev-server": "2.4.5"
"webpack": "3.3.0",
"webpack-dev-server": "2.5.1"
},
"devDependencies": {
"babel-cli": "6.24.1",
Expand All @@ -110,19 +98,19 @@
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-flow-strip-types": "6.22.0",
"babel-polyfill": "6.23.0",
"conventional-github-releaser": "1.1.11",
"conventional-github-releaser": "1.1.12",
"coveralls": "2.13.1",
"cz-conventional-changelog": "2.0.0",
"eslint-config-prettier": "2.2.0",
"eslint-plugin-flowtype": "2.34.0",
"flow-bin": "0.48.0",
"eslint-config-prettier": "2.3.0",
"eslint-plugin-flowtype": "2.35.0",
"flow-bin": "0.50.0",
"gemini": "5.0.0-alpha.3",
"html-reporter": "0.2.0",
"jest": "20.0.4",
"lint-staged": "3.4.0",
"lint-staged": "4.0.2",
"pmm": "1.3.1",
"pre-commit": "1.2.2",
"prettier": "1.4.4",
"prettier": "1.5.3",
"proq": "1.0.0",
"rimraf": "2.6.1",
"strip-ansi": "4.0.0"
Expand All @@ -133,11 +121,7 @@
}
},
"jest": {
"roots": [
"./src"
],
"collectCoverageFrom": [
"src/**/*.js"
]
"roots": ["./src"],
"collectCoverageFrom": ["src/**/*.js"]
}
}
18 changes: 4 additions & 14 deletions src/utils/error-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ const ESLINT_PARSE_ERROR = "Parsing error:";
* Checks whether error is syntax error.
*/
export function isSyntaxError(message: string): boolean {
return (
message.indexOf(SYNTAX_ERROR_LABEL) !== -1 ||
message.indexOf(SYNTAX_ERROR_LABEL_HUMAN_FRIENDLY) !== -1
);
return message.indexOf(SYNTAX_ERROR_LABEL) !== -1 || message.indexOf(SYNTAX_ERROR_LABEL_HUMAN_FRIENDLY) !== -1;
}

/**
Expand Down Expand Up @@ -81,14 +78,9 @@ export function formatSyntaxError(message: string): string {
const filePath = removeLinePadding(padding, messageByLine[0]);
const error = removeLinePadding(
padding,
messageByLine[1].replace(
"Module build failed: SyntaxError:",
SYNTAX_ERROR_LABEL_HUMAN_FRIENDLY
)
messageByLine[1].replace("Module build failed: SyntaxError:", SYNTAX_ERROR_LABEL_HUMAN_FRIENDLY)
);
const snippet = messageByLine
.filter(isFileSnippetLine)
.map(removeLinePadding.bind(null, padding));
const snippet = messageByLine.filter(isFileSnippetLine).map(removeLinePadding.bind(null, padding));

return `${chalk.red("Error:")}
Expand All @@ -106,9 +98,7 @@ export function formatEslintWarning(message: string): string {
const messageByLine = message.split("\n");
const padding = getLinePadding(messageByLine[0]);
const filePath = removeLinePadding(padding, messageByLine[0]);
const rule = messageByLine
.filter(isEslintWarningRuleLine)
.map(removeLinePadding.bind(null, padding + 2));
const rule = messageByLine.filter(isEslintWarningRuleLine).map(removeLinePadding.bind(null, padding + 2));

return `${rule.join("\n")}
Expand Down
9 changes: 3 additions & 6 deletions src/webpack/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export function htmlWebpackPlugin(template: string | false) {
}

export function npmInstallPlugin(options?: Object = {}) {
return new NpmInstallPlugin(
Object.assign({ dev: true, peerDependencies: true }, options)
);
return new NpmInstallPlugin(Object.assign({ dev: true, peerDependencies: true }, options));
}

/**
Expand All @@ -26,6 +24,7 @@ export function npmInstallPlugin(options?: Object = {}) {
export function pluginsProd(template: string | false): Array<any> {
return [
new webpack.DefinePlugin({ "process.env.NODE_ENV": '"production"' }),
new webpack.optimize.ModuleConcatenationPlugin(),
htmlWebpackPlugin(template),
npmInstallPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
Expand Down Expand Up @@ -66,7 +65,5 @@ export function pluginsDev(template: string | false): Array<any> {
* Setups plugins section for webpack config.
*/
export default function plugins(params: AikParams): Array<any> {
return params.isProd
? pluginsProd(params.template.path)
: pluginsDev(params.template.path);
return params.isProd ? pluginsProd(params.template.path) : pluginsDev(params.template.path);
}

0 comments on commit 5d0815b

Please sign in to comment.