https://github.com/saber2pr/webpack-configer
a function for webpack config using @types/webpack.
https://github.com/saber2pr/webpack-configer
typescript webpack
Last synced: about 2 months ago
JSON representation
a function for webpack config using @types/webpack.
- Host: GitHub
- URL: https://github.com/saber2pr/webpack-configer
- Owner: Saber2pr
- Created: 2019-05-22T13:31:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-12T01:51:00.000Z (about 7 years ago)
- Last Synced: 2025-02-14T02:42:21.046Z (over 1 year ago)
- Topics: typescript, webpack
- Language: TypeScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @saber2pr/webpack-configer
> T^T how to config webpack use declaration?
```bash
# from npm
npm install @saber2pr/webpack-configer
# from github
git clone https://github.com/Saber2pr/webpack-configer.git
```
# webpack.config.js
> typescript(tsx) + less
> auto compile, Minify
```js
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const CleanCSSPlugin = require('less-plugin-clean-css')
const path = require('path')
const extractLess = new ExtractTextPlugin('style.css')
const { WebpackConfig } = require('@saber2pr/webpack-configer')
// use declaration from @types/webpack
module.exports = WebpackConfig({
mode: 'development',
entry: './src/index.tsx',
resolve: {
extensions: ['.js', '.ts', '.tsx']
},
output: {
filename: 'bundle.js',
path: path.join(__dirname, 'build')
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000,
ignored: /node_modules/
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: ['ts-loader']
},
{
test: /\.less$/,
use: extractLess.extract({
use: [
{
loader: 'css-loader'
},
{
loader: 'less-loader',
options: {
plugins: [
new CleanCSSPlugin({
advanced: true
})
]
}
}
],
fallback: 'style-loader'
})
}
]
},
plugins: [new HtmlWebpackPlugin({}), extractLess]
})
```
## tsconfig.json
```json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"esModuleInterop": true,
"jsx": "react",
"lib": ["dom", "es2015"]
},
"exclude": ["node_modules", "lib"]
}
```
---
## start
```bash
npm install
```
```bash
npm start
npm test
```
> Author: saber2pr
---
## develope and test
> you should write ts in /src
> you should make test in /src/test
> export your core in /src/index.ts!