更新打包设置

This commit is contained in:
ChenX
2018-08-17 21:26:32 +08:00
parent c99f7f8149
commit 2ef48e17c6
8 changed files with 2290 additions and 46 deletions

38
config/webpack.common.ts Normal file
View File

@@ -0,0 +1,38 @@
import * as path from 'path';
import * as webpack from 'webpack';
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
const config: webpack.Configuration = {
devtool: "source-map",
//项目需要解析的文件拓展名称
resolve: {
extensions: [".ts", ".tsx", ".js", "json"]
},
externals: {
'three': "THREE"
},
//模块加载器设置
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
]
},
plugins: [
new HardSourceWebpackPlugin(),
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
]
}
export default config;

View File

@@ -1,47 +1,21 @@
import * as path from 'path';
import * as webpack from 'webpack';
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
import * as merge from 'webpack-merge';
import common from './webpack.common';
import * as path from 'path';
const config: webpack.Configuration = {
mode: "production",
entry: "./src/index.ts",
devtool: "source-map",
//输出设置
output: {
filename: "cad.js",
path: path.resolve(__dirname, '../umd'),
library: "cad",
libraryTarget: "umd"
},
//项目需要解析的文件拓展名称
resolve: {
extensions: [".ts", ".tsx", ".js", "json"]
},
externals: {
'three': "THREE"
},
//模块加载器设置
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
]
},
plugins: [
new HardSourceWebpackPlugin(),
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
]
}
const config: webpack.Configuration = merge(
common,
{
mode: "production",
entry: "../src/index.ts",
//输出设置
output: {
filename: "cad.js",
path: path.resolve(__dirname, '../umd'),
library: "cad",
libraryTarget: "umd"
},
}
);
export default config;

35
config/webpack.view.ts Normal file
View File

@@ -0,0 +1,35 @@
import * as webpack from 'webpack';
import * as merge from 'webpack-merge';
import common from './webpack.umd';
import * as HtmlWebPackPlugin from "html-webpack-plugin";
import * as path from 'path';
function getpath(fileName)
{
return path.resolve(__dirname, fileName);
}
const config: webpack.Configuration = merge(
common,
{
mode: "development",
entry: "./src/ViewSrc/index.ts",
output: { pathinfo: false },
devtool: "cheap-module-eval-source-map",
devServer: {
contentBase: "./dist/",
port: 7776,
hot: true
},
plugins: [
// new webpack.NamedModulesPlugin(),//Hot
// new webpack.HotModuleReplacementPlugin(),//Hot
new HtmlWebPackPlugin({
title: "webCAD",
// template: getpath('../src/index.html')
}),
]
}
);
export default config;