Skip to content

Commit

Permalink
add file directory
Browse files Browse the repository at this point in the history
  • Loading branch information
champion688 committed Jun 3, 2018
1 parent 12f136b commit 077848d
Show file tree
Hide file tree
Showing 9 changed files with 1,229 additions and 47 deletions.
47 changes: 34 additions & 13 deletions config/webpack.base.config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
/**
* @description webpack的基本配置
*/
"use strict"

'use strict'

const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const HtmlWebpackPlugin = require("html-webpack-plugin")
const path = require("path")

module.exports = {
entry: "./index.html",
entry: resolve("src/main.js"),
output: {
path: path.join(__dirname, '../dist'),
filename: '[name].[hash:4].js'
path: resolve("dist"),
filename: "[name].[hash:4].js"
},
resolve: {
extensions: [".js"],
alias: {
"@": resolve("src"),
"@components": resolve("@/components"),
"@lib": resolve("@components/lib"),
"@mock": resolve("@components/mock"),
"@api": resolve("@/api")
}
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
loader: "babel-loader",
query: {
presets:['es2015', 'react']
}
presets: ["es2015", "react"]
},
exclude: /node_modules/
},
{
test: /\.html$/,
loader: 'html-loader'
loader: "html-loader"
},
{
test: /\.css$/,
loader: 'css-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template:'index.html',
filename: "index.html",
template: "index.html",
inject: true
})
]
}

function resolve(dir) {
return path.join(__dirname, "..", dir)
}
7 changes: 5 additions & 2 deletions config/webpack.dev.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* webpack的开发配置
*/

'use strict'

const merge = require('webpack-merge')
Expand All @@ -8,9 +12,8 @@ const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
devtool: 'source-map',
devServer: {
contentBase: path.join(__dirname, '../src'),
contentBase: path.join(__dirname, '../dist'),
historyApiFallback:false,
host: false,
host: '0.0.0.0',
port: 3030
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<title>ucmp-react-ui</title>
</head>
<body>
hello world
<div id="app"></div>
</body>
</html>
Loading

0 comments on commit 077848d

Please sign in to comment.