Skip to content

Commit 5355386

Browse files
committed
добавлен пример нулевого конфига
1 parent 9a7f965 commit 5355386

File tree

7 files changed

+101
-0
lines changed

7 files changed

+101
-0
lines changed

examples/zero-config/.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [["es2015", { "modules": false }]],
3+
"plugins": [
4+
"transform-object-rest-spread",
5+
["transform-runtime", {
6+
"polyfill": false,
7+
"regenerator": true
8+
}],
9+
"syntax-dynamic-import"
10+
]
11+
}

examples/zero-config/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Example of using webpack in the root directory.
2+
3+
>Generated assets can overwrite standard assets in the assets directory

examples/zero-config/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "webpack-zero-config",
3+
"version": "1.0.0",
4+
"description": "",
5+
"scripts": {
6+
"yii2-webpack": "yii2-webpack",
7+
"yii2-webpack:default": "yii2-webpack --default-config",
8+
"dev": "yii2-webpack-exec --progress --yii2-webpack-config dev",
9+
"build": "yii2-webpack-exec --yii2-webpack-config prod"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "ISC",
14+
"dependencies": {
15+
"babel-cli": "^6.26.0",
16+
"babel-core": "^6.26.0",
17+
"babel-loader": "^7.1.4",
18+
"babel-plugin-component": "^1.1.1",
19+
"babel-plugin-syntax-dynamic-import": "^6.18.0",
20+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
21+
"babel-plugin-transform-runtime": "^6.23.0",
22+
"babel-preset-env": "^1.6.1",
23+
"babel-preset-es2015": "^6.24.1",
24+
"babel-preset-react": "^6.24.1",
25+
"npm": "^6.7.0",
26+
"webpack": "^4.6.0",
27+
"webpack-cli": "^3.2.3",
28+
"webpack-dev-server": "^3.1.14",
29+
"webpack-merge": "^4.1.2",
30+
"yii2-webpack": "^1.0.0"
31+
}
32+
}

examples/zero-config/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('hello world')
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
entry: {
3+
index: './src/index.js'
4+
},
5+
module: {
6+
rules: [
7+
{
8+
test: /\.js$/,
9+
exclude: file => (
10+
/node_modules/.test(file)
11+
),
12+
use: {
13+
loader: 'babel-loader',
14+
options: {
15+
presets: [['env', {'modules': false, 'targets': {'node': 4}}]]
16+
},
17+
},
18+
}
19+
],
20+
},
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const path = require('path')
2+
const merge = require('webpack-merge')
3+
const common = require('./webpack.common.js')
4+
const publicPath = 'http://localhost:8080/'
5+
6+
module.exports = merge.smart(common, {
7+
mode: 'development',
8+
output: {
9+
filename: '[name].js',
10+
chunkFilename: '[name].[hash].bundle.js',
11+
path: path.resolve(__dirname, 'dist'),
12+
publicPath: publicPath
13+
},
14+
devServer: {
15+
headers: {'Access-Control-Allow-Origin': '*'},
16+
disableHostCheck: true
17+
}
18+
})
19+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const path = require('path')
2+
const merge = require('webpack-merge')
3+
const common = require('./webpack.common.js')
4+
const publicPath = ''
5+
6+
module.exports = merge.smart(common, {
7+
mode: 'production',
8+
output: {
9+
filename: '[name].[hash].js',
10+
chunkFilename: '[id].[hash].js',
11+
path: path.resolve(__dirname, 'dist'),
12+
publicPath: publicPath
13+
}
14+
})

0 commit comments

Comments
 (0)