build updated
This commit is contained in:
1 parent
278426c219
commit
8e606be761
5 files changed
+110
-71
No files matched your search
@@ -1,4 +1,17 @@
|
||||
{
|
||||
"presets": ["es2015", "stage-0"],
|
||||
"plugins": ["transform-react-jsx"]
|
||||
"presets": [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "8.5.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": [
|
||||
"transform-react-jsx",
|
||||
"transform-object-rest-spread",
|
||||
"transform-class-properties"
|
||||
]
|
||||
}
|
||||
+5
-3
@@ -2,11 +2,13 @@
|
||||
FROM node:10 as build
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json gulpfile.js .babelrc ./
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm i
|
||||
|
||||
COPY webpack.config.js gulpfile.js .babelrc ./
|
||||
COPY robots.txt ./
|
||||
COPY src ./src
|
||||
RUN npm run gulp deploy
|
||||
RUN npm run build-app
|
||||
RUN npm run out
|
||||
|
||||
|
||||
@@ -14,7 +16,7 @@ RUN npm run out
|
||||
FROM node:8-alpine
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json gulpfile.babel.js .babelrc ./
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm i --production
|
||||
|
||||
COPY --from=build /app/out ./src
|
||||
|
||||
+2
-58
@@ -2,29 +2,10 @@ const gulp = require('gulp')
|
||||
const postcss = require('gulp-postcss')
|
||||
const sass = require('gulp-sass')
|
||||
const imageMin = require('gulp-imagemin')
|
||||
const uglify = require('gulp-uglify')
|
||||
const concat = require('gulp-concat')
|
||||
const webpack = require('webpack-stream')
|
||||
const named = require('vinyl-named')
|
||||
const autoprefixer = require('autoprefixer')
|
||||
const cssnano = require('cssnano')
|
||||
|
||||
let env = process.env['NODE_ENV'] || 'production'
|
||||
let isProduction = env === 'production'
|
||||
|
||||
gulp.task('compile 3rdparty', () => {
|
||||
const files = [
|
||||
'./node_modules/spin.js/spin.js',
|
||||
|
||||
'./node_modules/babel-polyfill/dist/polyfill.min.js'
|
||||
]
|
||||
|
||||
return gulp.src(files)
|
||||
.pipe(concat('libs.js'))
|
||||
.pipe(uglify())
|
||||
.pipe(gulp.dest('./public'))
|
||||
})
|
||||
|
||||
gulp.task('style', () => {
|
||||
const processors = [
|
||||
autoprefixer({
|
||||
@@ -67,49 +48,12 @@ gulp.task('copy views', () => {
|
||||
.pipe(gulp.dest('./out/views'))
|
||||
})
|
||||
|
||||
gulp.task('compile', () => {
|
||||
const doWatch = !isProduction
|
||||
const doSourceMaps = !isProduction
|
||||
|
||||
return gulp.src([
|
||||
'./src/public/app.js'
|
||||
])
|
||||
.pipe(named())
|
||||
.pipe(webpack({
|
||||
// devtool: doSourceMaps ? 'inline-source-map' : null,
|
||||
// watch: doWatch,
|
||||
output: {
|
||||
filename: '[name].js'
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{test: /\.js$/, loader: 'babel'},
|
||||
// {test: /\.html$/, loader: 'raw!html-minify'}
|
||||
]
|
||||
},
|
||||
// 'html-minify-loader': {
|
||||
// empty: true,
|
||||
// cdata: true,
|
||||
// comments: false,
|
||||
// dom: {
|
||||
// lowerCaseAttributeNames: false
|
||||
// }
|
||||
// }
|
||||
}))
|
||||
.pipe(gulp.dest('./public'))
|
||||
})
|
||||
|
||||
gulp.task('imagemin', () => {
|
||||
return gulp.src('./src/assets/graphics/**/*')
|
||||
.pipe(imageMin())
|
||||
.pipe(gulp.dest('./public/graphics'))
|
||||
})
|
||||
|
||||
gulp.task('production', () => {
|
||||
isProduction = true
|
||||
})
|
||||
|
||||
gulp.task('default', gulp.series('style'))
|
||||
gulp.task('copy', gulp.series('copy views', 'copy fonts', 'copy graphics', 'copy 3rdparty', 'copy robots.txt'))
|
||||
gulp.task('deploy', gulp.series('default', 'copy', 'compile 3rdparty', 'imagemin'))
|
||||
gulp.task('compile production', gulp.series('production', 'compile'))
|
||||
gulp.task('copy', gulp.series('copy views', 'copy fonts', 'copy graphics', 'copy robots.txt'))
|
||||
gulp.task('deploy', gulp.series('default', 'copy', 'imagemin'))
|
||||
+22
-8
@@ -6,6 +6,7 @@
|
||||
"main": "src/bin/www.js",
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"build-app": "webpack --env.NODE_ENV=production --env.TARGET=app",
|
||||
"out": "babel src/ -d out/",
|
||||
"gulp": "gulp",
|
||||
"test": "mocha --compilers js:babel-register",
|
||||
@@ -19,10 +20,6 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"async-file": "^2.0.2",
|
||||
"babel-core": "^6.7.4",
|
||||
"babel-polyfill": "^6.7.4",
|
||||
"babel-preset-es2015": "^6.5.0",
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"co": "^4.4.0",
|
||||
"ejson": "^2.1.2",
|
||||
"handlebars": "^4.0.5",
|
||||
@@ -53,10 +50,22 @@
|
||||
"thunkify": "^2.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.0.0-beta.47",
|
||||
"@babel/core": "^7.0.0-beta.47",
|
||||
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.47",
|
||||
"@babel/polyfill": "^7.0.0-beta.47",
|
||||
"@babel/preset-env": "^7.0.0-beta.47",
|
||||
"@babel/register": "^7.0.0-beta.47",
|
||||
"autoprefixer": "^6.3.6",
|
||||
"babel-cli": "^6.6.5",
|
||||
"babel-loader": "^6.2.2",
|
||||
"babel-loader": "^8.0.0-beta.3",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-plugin-transform-react-jsx": "^6.23.0",
|
||||
"babel-plugin-transform-regenerator": "^6.26.0",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-register": "^6.26.0",
|
||||
"css-loader": "^0.28.9",
|
||||
"cssnano": "^3.4.0",
|
||||
"eslint": "^3.9.1",
|
||||
"eslint-config-standard": "^6.2.1",
|
||||
@@ -69,14 +78,19 @@
|
||||
"gulp-imagemin": "~2.4.0",
|
||||
"gulp-postcss": "^6.0.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-sass": "^3.1.0",
|
||||
"gulp-sass": "^4.0.1",
|
||||
"gulp-uglify": "~1.5.0",
|
||||
"html-minify-loader": "~1.1.0",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"istanbul": "~0.4.2",
|
||||
"less": "^3.0.4",
|
||||
"less-loader": "^4.1.0",
|
||||
"mocha": "~2.4.5",
|
||||
"raw-loader": "~0.5.1",
|
||||
"should": "^8.2.2",
|
||||
"style-loader": "^0.20.2",
|
||||
"vinyl-named": "~1.1.0",
|
||||
"webpack-stream": "~3.1.0"
|
||||
"webpack": "^3.11.0",
|
||||
"webpack-merge": "^4.1.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
const path = require('path')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
|
||||
const targetDir = path.resolve(__dirname, 'public')
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
app: './src/public/app.js',
|
||||
},
|
||||
output: {
|
||||
path: targetDir,
|
||||
filename: '[name].js',
|
||||
},
|
||||
|
||||
devtool: 'cheap-module-source-map',
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.jsx?/,
|
||||
use: [{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
babelrc: false,
|
||||
presets: [
|
||||
['@babel/preset-env', {
|
||||
'targets': {
|
||||
'browsers': [
|
||||
'last 2 Chrome versions',
|
||||
'last 2 Safari versions',
|
||||
'last 2 Firefox versions',
|
||||
'last 2 Edge versions',
|
||||
]
|
||||
}
|
||||
}]
|
||||
],
|
||||
|
||||
plugins: [
|
||||
'@babel/plugin-proposal-object-rest-spread',
|
||||
'@babel/plugin-proposal-class-properties',
|
||||
'transform-react-jsx',
|
||||
]
|
||||
},
|
||||
}]
|
||||
},
|
||||
|
||||
{
|
||||
test: /\.less/,
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
{
|
||||
loader: 'less-loader',
|
||||
options: {
|
||||
root: true
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
plugins: [
|
||||
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user