-
-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change template to align more with generators package
change the internal structure of template files
- Loading branch information
Showing
31 changed files
with
360 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
packages/create-webpack-app/templates/default/package.json.hbs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/create-webpack-app/templates/default/webpack.config.js.hbs
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
packages/create-webpack-app/templates/init/default/package.json.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ "version": "1.0.0", "description": "My webpack project", "name": "{{projectName}}", "scripts": { | ||
"build": "webpack --mode=production --node-env=production", "build:dev": "webpack | ||
--mode=development", "build:prod": "webpack --mode=production --node-env=production", "watch": | ||
"webpack --watch", | ||
{{#if devServer}} | ||
"serve": "webpack serve" | ||
{{/if}} | ||
} } |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
packages/create-webpack-app/templates/init/default/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Hello, World!"); |
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions
75
packages/create-webpack-app/templates/init/default/webpack.configjs.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Generated using webpack-cli https://github.com/webpack/webpack-cli const path = require('path'); | ||
{{#if (htmlWebpackPlugin)}} | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
{{/if}} | ||
{{#isEqualToString extractPlugin "No"}} | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
{{/isEqualToString}} | ||
{{#if (workboxWebpackPlugin)}} | ||
const WorkboxWebpackPlugin = require('workbox-webpack-plugin>) | ||
{{/if}} | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
{{!-- {{#isEqualToString cssType 'none'}} --}} | ||
{{!-- {{#if ({{extractPlugin === "Yes"}})}} --}} | ||
{{! const stylesHandler = MiniCssExtractPlugin.loader; }} | ||
{{!-- {{else ({{if extractPlugin === "Only for Production"}})}} --}} | ||
{{! const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : 'style-loader'; }} | ||
{{!-- {{else}} --}} | ||
{{! const stylesHandler = 'style-loader'; }} | ||
{{!-- {{/if}} --}} | ||
{{!-- {{/isEqualToString}} --}} | ||
|
||
const config = { entry: '{{entry}}', output: { path: path.resolve(__dirname, 'dist'), },{{#if | ||
(devServer) | ||
}} | ||
devServer: { open: true, host: 'localhost', },{{/if}} | ||
plugins: [{{#if (htmlWebpackPlugin)}} | ||
new HtmlWebpackPlugin({ template: 'index.html', }), | ||
{{/if}} | ||
{{#isEqualToString extractPlugin "Yes"}} | ||
new MiniCssExtractPlugin(), | ||
{{/isEqualToString}} | ||
// Add your plugins here // Learn more about plugins from | ||
https://webpack.js.org/configuration/plugins/ ], module: { rules: [{{#isEqualToString | ||
langType "ES6" | ||
}} | ||
{ test: /\.(js|jsx)$/i, loader: 'babel-loader', },{{/isEqualToString}} | ||
{{#isEqualToString langType "Typescript"}} | ||
{ test: /\.(ts|tsx)$/i, loader: 'ts-loader', exclude: ['/node_modules/'], },{{/isEqualToString}}{{#if | ||
isCSS | ||
}} | ||
{{#unless isPostCSS}} | ||
{ test: /\.css$/i, use: [stylesHandler,'css-loader'], },{{/unless}}{{/if}}{{#isEqualToString | ||
cssType "SASS" | ||
}} | ||
{ test: /\.s[ac]ss$/i, use: [stylesHandler, 'css-loader', | ||
{{#if (isPostCSS)}}'postcss-loader', {{/if}}'sass-loader'], },{{/isEqualToString}}{{#isEqualToString | ||
cssType "LESS" | ||
}} | ||
{ test: /\.less$/i, use: [stylesHandler, 'css-loader', | ||
{{#if (isPostCSS)}}'postcss-loader', {{/if}}'less-loader'], },{{/isEqualToString}}{{#isEqualToString | ||
cssType "Stylus" | ||
}} | ||
{ test: /\.styl$/i, use: [stylesHandler, 'css-loader', | ||
{{#if (isPostCSS)}}'postcss-loader', {{/if}}'stylus-loader'], },{{/isEqualToString}}{{#if | ||
(isPostCSS) | ||
}} | ||
{{#if (isCSS)}} | ||
{ test: /\.css$/i, use: [stylesHandler, 'css-loader', 'postcss-loader'], },{{/if}}{{/if}} | ||
{ test: /\.(eot|svg|ttf|woff|woff2|png|jpg|g#if)$/i, type: 'asset', }, | ||
{{#if (htmlWebpackPlugin)}} | ||
{ test: /\.html$/i, use: ['html-loader'], },{{/if}} | ||
|
||
// Add your rules for custom modules here // Learn more about loaders from | ||
https://webpack.js.org/loaders/ ], }, | ||
{{#isEqualToString langType "Typescript"}} | ||
resolve: { extensions: ['.tsx', '.ts', '.jsx', '.js', '...'], },{{/isEqualToString}} | ||
}; module.exports = () => { if (isProduction) { config.mode = 'production'; | ||
{{#isEqualToString extractPlugin "Only for Production"}} | ||
config.plugins.push(new MiniCssExtractPlugin()); | ||
{{/isEqualToString}} | ||
{{#if (workboxWebpackPlugin)}} | ||
config.plugins.push(new WorkboxWebpackPlugin.GenerateSW()); | ||
{{/if}} | ||
} else { config.mode = 'development'; } return config; }; |
8 changes: 8 additions & 0 deletions
8
packages/create-webpack-app/templates/init/react/index.d.ts.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare module "*.png"; | ||
declare module "*.jpg"; | ||
declare module "*.gif"; | ||
declare module "*.svg"; | ||
declare module "*.ttf"; | ||
declare module "*.woff"; | ||
declare module "*.woff2"; | ||
declare module "*.eot"; |
12 changes: 12 additions & 0 deletions
12
packages/create-webpack-app/templates/init/react/index.html.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Webpack + React</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
packages/create-webpack-app/templates/init/react/package.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "1.0.0", | ||
"description": "My webpack project", | ||
"name": "my-webpack-project", | ||
"scripts": { | ||
"build": "webpack --mode=production --node-env=production", | ||
"build:dev": "webpack --mode=development", | ||
"build:prod": "webpack --mode=production --node-env=production", | ||
"watch": "webpack --watch", | ||
"serve": "webpack serve" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/create-webpack-app/templates/init/react/src/App.js.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
import webpackLogo from "./assets/webpack.png"; | ||
|
||
function App() { | ||
return ( | ||
<div className="container"> | ||
<h1 className="heading">Welcome to your React App!</h1> | ||
<img src={webpackLogo} alt="webpack logo" /> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
13 changes: 13 additions & 0 deletions
13
packages/create-webpack-app/templates/init/react/src/App.tsx.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
import webpackLogo from "./assets/webpack.png"; | ||
|
||
function App() { | ||
return ( | ||
<div className="container"> | ||
<h1 className="heading">Welcome to your Typescript React App!</h1> | ||
<img src={webpackLogo} alt="webpack logo" /> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
Binary file added
BIN
+2.28 KB
packages/create-webpack-app/templates/init/react/src/assets/webpack.png.tpl
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
packages/create-webpack-app/templates/init/react/src/index.js.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './App'; | ||
<% if (cssType == 'CSS only') { %> | ||
import "./styles/global.css";<% } if (cssType == 'SASS') { %> | ||
import "./styles/global.scss";<% } if (cssType == 'LESS') { %> | ||
import "./styles/global.less";<% } if (cssType == 'Stylus') { %> | ||
import "./styles/global.styl";<% } %> | ||
|
||
const container = document.getElementById('root'); | ||
const root = createRoot(container); | ||
root.render(<App />); |
12 changes: 12 additions & 0 deletions
12
packages/create-webpack-app/templates/init/react/src/index.tsx.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './App'; | ||
<% if (cssType == 'CSS only') { %> | ||
import "./styles/global.css";<% } if (cssType == 'SASS') { %> | ||
import "./styles/global.scss";<% } if (cssType == 'LESS') { %> | ||
import "./styles/global.less";<% } if (cssType == 'Stylus') { %> | ||
import "./styles/global.styl";<% } %> | ||
|
||
const container = document.getElementById('root'); | ||
const root = createRoot(container); | ||
root.render(<App />); |
18 changes: 18 additions & 0 deletions
18
packages/create-webpack-app/templates/init/react/src/styles/global.css.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
|
||
.heading { | ||
font-weight: 300; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/create-webpack-app/templates/init/react/src/styles/global.less.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
|
||
.heading { | ||
font-weight: 300; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/create-webpack-app/templates/init/react/src/styles/global.scss.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
|
||
.heading { | ||
font-weight: 300; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/create-webpack-app/templates/init/react/src/styles/global.styl.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
|
||
.heading { | ||
font-weight: 300; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/create-webpack-app/templates/init/react/tsconfig.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"allowSyntheticDefaultImports": true, | ||
"noImplicitAny": true, | ||
"module": "es6", | ||
"target": "es5", | ||
"allowJs": true, | ||
"moduleResolution": "node" | ||
}, | ||
"files": ["src/index.tsx", "index.d.ts"] | ||
} |
Oops, something went wrong.