fix: build script

This commit is contained in:
Bogdan Lyashenko
2019-07-02 20:41:58 +02:00
parent 0cf67aa8bb
commit 72776eee35
7 changed files with 38 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
.idea
example-project
docs
docs
src/public/js

View File

@@ -15,9 +15,9 @@
"server-dev": "nodemon src/index.dev.js",
"server-debug": "nodemon --inspect src/index.dev.js",
"clean": "rm -rf src/public/dist/standalone-build",
"babel-compile": "babel src/public/js -d src/public/dist/standalone-build --config-file ./src/public/babel.config.js --copy-files",
"build": "yarn clean && node scripts/index.js && yarn babel-compile && yarn client-dev",
"start:standalone": "cd src/public/dist/standalone && http-server",
"babel-compile-standalone": "babel src/public/js -d src/public/dist/standalone-build --config-file ./src/public/babel.config.js --copy-files",
"webpack-compile-local": "cd src/public && webpack --config webpack.local.js --progress",
"build": "yarn clean && yarn babel-compile-standalone && yarn webpack-compile-local",
"pretty": "prettier --write \"./src/public/js/**/*.js\""
},
"bin": {
@@ -57,12 +57,14 @@
"@babel/cli": "^7.4.4",
"@babel/core": "^7.1.2",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@commitlint/cli": "^7.3.2",
"@commitlint/config-conventional": "^7.3.1",
"babel-loader": "^8.0.4",
"babel-plugin-import": "^1.9.1",
"babel-plugin-transform-define": "^1.3.1",
"css-loader": "^0.28.11",
"husky": "^1.3.1",
"node-sass": "^4.9.3",

View File

@@ -1,11 +0,0 @@
const fs = require('fs');
const { version } = require('../package.json');
const metaInfo = `export default { version: '${version}' }`;
const writeMetaInfo = path =>
fs.writeFile(path, metaInfo, err => {
if (err) console.log(err);
});
writeMetaInfo('src/public/js/meta.js');

View File

@@ -1,19 +1,31 @@
const packageJson = require('../../package');
module.exports = function(app) {
app.cache(true);
const presets = [
'@babel/preset-react',
[
'@babel/preset-env',
{
useBuiltIns: 'usage'
targets: {
browsers: ['last 2 versions']
},
modules: false
}
]
],
'@babel/preset-react'
];
const plugins = [
['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
'@babel/plugin-syntax-dynamic-import'
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-runtime',
[
'transform-define',
{
'process.env.CODECRUMBS_VERSION': packageJson.version
}
]
];
return {

View File

@@ -1 +1 @@
export default { version: '1.5.6' }
export default { version: process.env.CODECRUMBS_VERSION }

View File

@@ -29,7 +29,7 @@ module.exports = {
},
{
test: /\.css$/,
include: /node_modules/,
include: [path.resolve(__dirname, '../../node_modules/antd/')],
use: ['style-loader', 'css-loader']
}
]

View File

@@ -0,0 +1,13 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
plugins: [
new webpack.DefinePlugin({
'process.env.LOCAL': JSON.stringify(true)
})
]
});