Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
Add webpack target node (#36)
Browse files Browse the repository at this point in the history
* Set webpack target to node

* Remove unused import

* Update CHANGELOG

* Build multiple target

* Use web config for styleguidist
  • Loading branch information
krazijames committed Jan 18, 2019
1 parent 6083d81 commit a416737
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 57 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- Implement `Options` component. (#33)
- Add webpack target `node` (#36)

## [0.0.1] - 2019-01-18
- Initial release.
1 change: 0 additions & 1 deletion packages/web-ui/src/Book/LandscapeBook/styles.ts
@@ -1,4 +1,3 @@
import css from "@emotion/css";
import { TextAlignProperty } from "csstype";

export const landscapeBook = {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-ui/styleguide.config.js
@@ -1,6 +1,6 @@
const path = require('path');
const { parse: propsParser } = require('react-docgen-typescript');
const webpackConfig = require('./webpack.config');
const webpackConfig = require('./webpack.config.web');
const pkg = require('./package.json');

module.exports = {
Expand Down
54 changes: 54 additions & 0 deletions packages/web-ui/webpack.config.common.js
@@ -0,0 +1,54 @@
const CleanWebpackPlugin = require('clean-webpack-plugin');
const { CheckerPlugin } = require('awesome-typescript-loader');
const path = require('path');

const srcDir = path.join(__dirname, 'src');
const outDir = path.join(__dirname, 'dist');

module.exports = {
entry: path.join(srcDir, 'index.ts'),
output: {
path: outDir,
},
mode: 'production',
devtool: 'source-map',
externals: {
react: 'react',
'react-dom': 'react-dom',
'react-dom/server': 'react-dom/server',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
enforce: 'pre',
test: /\.(ts|tsx)$/,
include: srcDir,
use: ['tslint-loader'],
},
{
test: /\.(ts|tsx)$/,
include: srcDir,
use: ['babel-loader', 'awesome-typescript-loader'],
},
{
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: false,
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin([outDir]),
new CheckerPlugin(),
],
};
61 changes: 6 additions & 55 deletions packages/web-ui/webpack.config.js
@@ -1,56 +1,7 @@
const CleanWebpackPlugin = require('clean-webpack-plugin');
const { CheckerPlugin } = require('awesome-typescript-loader');
const path = require('path');
const webConfig = require('./webpack.config.web');
const nodeConfig = require('./webpack.config.node');

const srcDir = path.join(__dirname, 'src');
const outDir = path.join(__dirname, 'dist');

module.exports = {
entry: path.join(srcDir, 'index.ts'),
output: {
path: outDir,
filename: 'index.js',
libraryTarget: 'commonjs2',
},
mode: 'production',
devtool: 'source-map',
externals: {
react: 'react',
'react-dom': 'react-dom',
'react-dom/server': 'react-dom/server',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
enforce: 'pre',
test: /\.(ts|tsx)$/,
include: srcDir,
use: ['tslint-loader'],
},
{
test: /\.(ts|tsx)$/,
include: srcDir,
use: ['babel-loader', 'awesome-typescript-loader'],
},
{
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: false,
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin([outDir]),
new CheckerPlugin(),
],
};
module.exports = [
webConfig,
nodeConfig,
];
13 changes: 13 additions & 0 deletions packages/web-ui/webpack.config.node.js
@@ -0,0 +1,13 @@
const _ = require('lodash');
const commonConfig = require('./webpack.config.common');

module.exports = _.merge({},
commonConfig,
{
target: 'node',
output: {
filename: 'index.node.js',
libraryTarget: 'commonjs2',
},
},
);
12 changes: 12 additions & 0 deletions packages/web-ui/webpack.config.web.js
@@ -0,0 +1,12 @@
const _ = require('lodash');
const commonConfig = require('./webpack.config.common');

module.exports = _.merge({},
commonConfig,
{
output: {
filename: 'index.js',
libraryTarget: 'commonjs2',
},
},
);

0 comments on commit a416737

Please sign in to comment.