Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
webpack.config.js that optionally supports typescript .ts files via t…
Browse files Browse the repository at this point in the history
…s-loader
  • Loading branch information
drnic committed Jun 21, 2018
1 parent a15bbc6 commit f715782
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions generators/assets/webpack/templates/webpack.config.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const configurator = {
return
}

let key = entry.replace(/(\.\/assets\/(js|css|go)\/)|\.(js|s[ac]ss|go)/g, '')
if(key.startsWith("_") || (/(js|s[ac]ss|go)$/i).test(entry) == false) {
let key = entry.replace(/(\.\/assets\/(src|js|css|go)\/)|\.(ts|js|s[ac]ss|go)/g, '')
if(key.startsWith("_") || (/(ts|js|s[ac]ss|go)$/i).test(entry) == false) {
return
}

Expand All @@ -34,7 +34,6 @@ const configurator = {

entries[key].push(entry)
})

return entries
},

Expand All @@ -43,7 +42,7 @@ const configurator = {
new CleanObsoleteChunks(),
new Webpack.ProvidePlugin({$: "jquery",jQuery: "jquery"}),
new MiniCssExtractPlugin({filename: "[name].[contenthash].css"}),
new CopyWebpackPlugin([{from: "./assets",to: ""}], {copyUnmodified: true,ignore: ["css/**", "js/**"] }),
new CopyWebpackPlugin([{from: "./assets",to: ""}], {copyUnmodified: true,ignore: ["css/**", "js/**", "src/**"] }),
new Webpack.LoaderOptionsPlugin({minimize: true,debug: false}),
new ManifestPlugin({fileName: "manifest.json"})
];
Expand All @@ -62,6 +61,7 @@ const configurator = {
{ loader: "sass-loader", options: {sourceMap: true}}
]
},
{ test: /\.tsx?$/, use: "ts-loader", exclude: /node_modules/},
{ test: /\.jsx?$/,loader: "babel-loader",exclude: /node_modules/ },
{ test: /\.(woff|woff2|ttf|svg)(\?v=\d+\.\d+\.\d+)?$/,use: "url-loader"},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,use: "file-loader" },
Expand All @@ -79,7 +79,10 @@ const configurator = {
entry: configurator.entries(),
output: {filename: "[name].[hash].js", path: `${__dirname}/public/assets`},
plugins: configurator.plugins(),
module: configurator.moduleOptions()
module: configurator.moduleOptions(),
resolve: {
extensions: ['.ts', '.js', '.json']
}
}

if( env === "development" ){
Expand All @@ -104,4 +107,4 @@ const configurator = {
}
}

module.exports = configurator.buildConfig()
module.exports = configurator.buildConfig()

0 comments on commit f715782

Please sign in to comment.