From 9152728a9345340720ca6cf5815c61130579c8f9 Mon Sep 17 00:00:00 2001 From: Cheton Wu Date: Sun, 21 Jul 2019 19:54:38 +0800 Subject: [PATCH] fix broken build --- .babelrc | 7 ------- babel.config.js | 7 +++++++ webpack.config.js | 30 ++++++++++++++++++++---------- 3 files changed, 27 insertions(+), 17 deletions(-) delete mode 100644 .babelrc create mode 100644 babel.config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 2f1ae00..0000000 --- a/.babelrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@trendmicro/babel-config", - "presets": [ - "@babel/preset-env", - "@babel/preset-react" - ] -} diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..728d703 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,7 @@ +module.exports = { + extends: '@trendmicro/babel-config', + presets: [ + '@babel/preset-env', + '@babel/preset-react' + ] +}; diff --git a/webpack.config.js b/webpack.config.js index aaa2f7f..f1d92ad 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,8 +1,24 @@ +const path = require('path'); +const findImports = require('find-imports'); const webpack = require('webpack'); +const pkg = require('./package.json'); +const babelConfig = require('./babel.config'); module.exports = { - mode: 'production', + mode: 'development', devtool: 'source-map', + entry: { + [pkg.name]: path.resolve(__dirname, 'src/index.js') + }, + output: { + path: path.join(__dirname, 'lib'), + filename: 'index.js', + libraryTarget: 'commonjs2' + }, + externals: [] + .concat(findImports(['src/**/*.{js,jsx}'], { flatten: true })) + .concat(Object.keys(pkg.peerDependencies)) + .concat(Object.keys(pkg.dependencies)), module: { rules: [ { @@ -14,14 +30,8 @@ module.exports = { { test: /\.jsx?$/, loader: 'babel-loader', - exclude: /node_modules/ - }, - { - test: /\.css$/, - use: [ - 'style-loader', - 'css-loader' - ] + exclude: /node_modules/, + options: babelConfig }, ] }, @@ -31,7 +41,7 @@ module.exports = { // This has effect on the react lib size NODE_ENV: JSON.stringify('production') } - }) + }), ], resolve: { extensions: ['.js', '.json', '.jsx']