diff --git a/.babelrc b/.babelrc index 7c2a047..2f73205 100644 --- a/.babelrc +++ b/.babelrc @@ -4,13 +4,12 @@ "targets": { "node": true, "uglify": false - }, - "spec": true, - "debug": false + } }] ], "plugins": [ "babel-plugin-transform-class-properties", - "babel-plugin-syntax-dynamic-import" + "babel-plugin-transform-runtime", + "babel-plugin-dynamic-import-node" ] } \ No newline at end of file diff --git a/.dockerignore b/.dockerignore index 9916791..85dfff8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,11 +22,12 @@ build/Release # Dependency directory # Deployed apps should consider commenting this line out: # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git -node_modules/** -!node_modules/.gitkeep +**/node_modules/** +!**/node_modules/.gitkeep # Webpack output -/dist +packages/*/dist +packages/*/lib # Intermediate build files (cache, etc.) /build diff --git a/.eslintignore b/.eslintignore index 23a9be9..c112c0f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -22,11 +22,12 @@ build/Release # Dependency directory # Deployed apps should consider commenting this line out: # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git -node_modules/** -!node_modules/.gitkeep +**/node_modules/** +!**/node_modules/.gitkeep # Webpack output -/dist +packages/*/dist +packages/*/lib # Intermediate build files (cache, etc.) /build diff --git a/.eslintrc.yml b/.eslintrc.yml index 3f2c139..177798b 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -12,8 +12,19 @@ env: es6: true rules: - no-underscore-dangle: 'off' + no-console: off no-plusplus: - error - allowForLoopAfterthoughts: true + no-underscore-dangle: 'off' react/no-array-index-key: 0 + +overrides: + - files: + - "config/**" + - "**/webpack.config*.js" + - "**/.babelrc*" + rules: + import/no-extraneous-dependencies: + - error + - devDependencies: true diff --git a/.gitignore b/.gitignore index 23a9be9..c112c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,11 +22,12 @@ build/Release # Dependency directory # Deployed apps should consider commenting this line out: # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git -node_modules/** -!node_modules/.gitkeep +**/node_modules/** +!**/node_modules/.gitkeep # Webpack output -/dist +packages/*/dist +packages/*/lib # Intermediate build files (cache, etc.) /build diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml index a049d57..40cbcf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,16 @@ -sudo: false - -language: node_js -node_js: - - 6 - -before_install: - - npm install codecov.io coveralls - -after_success: - - cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js - - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js - -branches: - only: - - master +# sudo: false +# +# language: node_js +# node_js: +# - 6 +# +# before_install: +# - npm install codecov.io coveralls +# +# after_success: +# - cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js +# - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js +# +# branches: +# only: +# - master diff --git a/Dockerfile.dist b/Dockerfile.dist deleted file mode 100644 index 6795de2..0000000 --- a/Dockerfile.dist +++ /dev/null @@ -1,4 +0,0 @@ -FROM icedream/caddy - -WORKDIR /data -COPY ./dist/ /data diff --git a/Jenkinsfile b/Jenkinsfile index 723563d..93ff925 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,29 +1,29 @@ -node("docker && linux && amd64") { - checkout scm - - docker.image("node:8.2.1").inside { - // Install dependencies - sh "npm install" - - // Build website with npm - sh "npm run build" - archive "dist/**" - } - - // Build docker image to be deployed - def image = docker.build("docker.dreamnetwork.oss:5000/icedream/carl-kittelberger-website:${env.BRANCH_NAME ?: "latest"}", "-f Dockerfile.dist .") - - // @NOTE - https://issues.jenkins-ci.org/browse/JENKINS-42152?focusedCommentId=307976&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-307976 - image.push() - if (env.BRANCH_NAME) { - switch(env.BRANCH_NAME) { - case "master": - image.push("latest") - break - default: - image.push() - break - } - } - image.push("${sh(script: "git describe --tags --always", returnStdout: true).trim()}") -} +// node("docker && linux && amd64") { +// checkout scm +// +// docker.image("node:8.2.1").inside { +// // Install dependencies +// sh "npm install" +// +// // Build website with npm +// sh "npm run build" +// archive "dist/**" +// } +// +// // Build docker image to be deployed +// def image = docker.build("docker.dreamnetwork.oss:5000/icedream/carl-kittelberger-website:${env.BRANCH_NAME ?: "latest"}", "-f Dockerfile.dist .") +// +// // @NOTE - https://issues.jenkins-ci.org/browse/JENKINS-42152?focusedCommentId=307976&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-307976 +// image.push() +// if (env.BRANCH_NAME) { +// switch(env.BRANCH_NAME) { +// case "master": +// image.push("latest") +// break +// default: +// image.push() +// break +// } +// } +// image.push("${sh(script: "git describe --tags --always", returnStdout: true).trim()}") +// } diff --git a/config/webpack/environment.js b/config/webpack/environment.js new file mode 100644 index 0000000..fd9497f --- /dev/null +++ b/config/webpack/environment.js @@ -0,0 +1,133 @@ +import autoprefixer from 'autoprefixer'; + +export default class Environment { + constructor(options) { + this.development = true; + this.production = false; + this.server = false; + + this.autoprefixerTargets = [ + '> 1%', + 'last 4 versions', + 'Firefox ESR', + 'ios >= 8', + ]; + this.locales = ['en']; + + if (options !== undefined && options !== null) { + this.input(options); + } + } + + input(options) { + if (options) { + switch (true) { + case typeof (options) === 'string': // string + this.inputString(options); + break; + + case Array.isArray(options): // array + options.forEach((arg) => { this.input(arg); }); + break; + + default: // object + Object.keys(options).forEach((k) => { + this[k] = options[k] || this[k]; + }); + break; + } + } else if (process.env.NODE_ENV) { + this.inputString(process.env.NODE_ENV); + } + } + + inputString(env) { + switch (env.toLowerCase()) { + case 'development': + this.development = true; + this.production = false; + break; + case 'production': + this.development = false; + this.production = true; + break; + case 'server': + this.server = true; + break; + default: + console.warn('Unknown environment:', env); + break; + } + } + + styleLoaders(...preprocessingLoaders) { + const { + production, + autoprefixerTargets, + server, + + ExtractTextPlugin, // @HACK + } = this; + + if (!ExtractTextPlugin) { + throw new Error('Need a valid ExtractTextPlugin fed into the environment object.'); + } + + let cssLoaders = [ + { + loader: 'style-loader', + }, + { + loader: 'css-loader', + options: { + importLoaders: 1, + sourceMap: true, + modules: true, + localIdentName: production + ? '[name]__[local]--[hash:base64:5]' + : '[name]__[local]--[hash:base64:5]', + }, + }, + { + loader: 'postcss-loader', + options: { + ident: 'postcss', + plugins: [ + autoprefixer({ + browsers: autoprefixerTargets, + grid: false, + }), + ], + sourceMap: true, + }, + }, + ].filter(loader => loader !== false); + + if (preprocessingLoaders && preprocessingLoaders.length > 0) { + cssLoaders.push( + { + loader: 'resolve-url-loader', + options: { + fail: true, + silent: false, + }, + }, + ...preprocessingLoaders.map(loader => Object.assign({}, loader, { + options: Object.assign({}, loader.options || {}, { + sourceMap: true, + }), + })), + ); + } + + if (!server) { + const fallback = cssLoaders.shift(); + cssLoaders = ExtractTextPlugin.extract({ + fallback, + use: cssLoaders, + }); + } + + return cssLoaders; + } +} diff --git a/config/webpack/injectManifestPlugin.js b/config/webpack/injectManifestPlugin.js new file mode 100644 index 0000000..11d044b --- /dev/null +++ b/config/webpack/injectManifestPlugin.js @@ -0,0 +1,26 @@ +/** + * Plugin for HtmlPlugin which inlines content for an extracted Webpack manifest + * into the HTML in a \n$1`); + // Remove the manifest from HtmlPlugin's assets to prevent a \n$1`); - // Remove the manifest from HtmlPlugin's assets to prevent a